예제 #1
0
        /// <summary>
        /// Checks if there's an association between the element and a Linedef
        /// </summary>
        /// <param name="linedef">Linedef to check the association against</param>
        /// <returns>true if the Linedef and the element are associated, false if not</returns>
        private bool IsAssociatedToLinedef(Linedef linedef)
        {
            // Doom style reference from linedef to sector?
            if (General.Map.Config.LineTagIndicatesSectors && element is Sector)
            {
                if (linedef.Action > 0 && tags.Overlaps(linedef.Tags))
                {
                    return(true);
                }
            }

            // Known action on this line?
            if ((linedef.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(linedef.Action))
            {
                LinedefActionInfo action = General.Map.Config.LinedefActions[linedef.Action];
                if (((action.Args[0].Type == (int)type) && (linedef.Args[0] != 0) && (tags.Contains(linedef.Args[0]))) ||
                    ((action.Args[1].Type == (int)type) && (linedef.Args[1] != 0) && (tags.Contains(linedef.Args[1]))) ||
                    ((action.Args[2].Type == (int)type) && (linedef.Args[2] != 0) && (tags.Contains(linedef.Args[2]))) ||
                    ((action.Args[3].Type == (int)type) && (linedef.Args[3] != 0) && (tags.Contains(linedef.Args[3]))) ||
                    ((action.Args[4].Type == (int)type) && (linedef.Args[4] != 0) && (tags.Contains(linedef.Args[4]))))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        // This is called to perform a search (and replace)
        // Returns a list of items to show in the results list
        // replacewith is null when not replacing
        public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
        {
            List <FindReplaceObject> objs = new List <FindReplaceObject>();

            // Interpret the number given
            int index = 0;

            if (int.TryParse(value, out index))
            {
                Linedef l = General.Map.Map.GetLinedefByIndex(index);
                if (l != null)
                {
                    LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
                    if (!info.IsNull)
                    {
                        objs.Add(new FindReplaceObject(l, "Linedef " + index + " (" + info.Title + ")"));
                    }
                    else
                    {
                        objs.Add(new FindReplaceObject(l, "Linedef " + index));
                    }
                }
            }

            return(objs.ToArray());
        }
예제 #3
0
        // This renders the associated sectors/linedefs with the indication color
        public void PlotReverseAssociations(IRenderer2D renderer, Association asso)
        {
            // Tag must be above zero
            if (asso.tag <= 0)
            {
                return;
            }

            // Doom style referencing to sectors?
            if (General.Map.Config.LineTagIndicatesSectors && (asso.type == UniversalType.SectorTag))
            {
                // Linedefs
                foreach (Linedef l in General.Map.Map.Linedefs)
                {
                    // Any action on this line?
                    if (l.Action > 0)
                    {
                        if (l.Tag == asso.tag)
                        {
                            renderer.PlotLinedef(l, General.Colors.Indication);
                        }
                    }
                }
            }
            else
            {
                // Linedefs
                foreach (Linedef l in General.Map.Map.Linedefs)
                {
                    // Known action on this line?
                    if ((l.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(l.Action))
                    {
                        LinedefActionInfo action = General.Map.Config.LinedefActions[l.Action];
                        if ((action.Args[0].Type == (int)asso.type) && (l.Args[0] == asso.tag))
                        {
                            renderer.PlotLinedef(l, General.Colors.Indication);
                        }
                        if ((action.Args[1].Type == (int)asso.type) && (l.Args[1] == asso.tag))
                        {
                            renderer.PlotLinedef(l, General.Colors.Indication);
                        }
                        if ((action.Args[2].Type == (int)asso.type) && (l.Args[2] == asso.tag))
                        {
                            renderer.PlotLinedef(l, General.Colors.Indication);
                        }
                        if ((action.Args[3].Type == (int)asso.type) && (l.Args[3] == asso.tag))
                        {
                            renderer.PlotLinedef(l, General.Colors.Indication);
                        }
                        if ((action.Args[4].Type == (int)asso.type) && (l.Args[4] == asso.tag))
                        {
                            renderer.PlotLinedef(l, General.Colors.Indication);
                        }
                    }
                }
            }
        }
예제 #4
0
        // This runs the check
        public override void Run()
        {
            int progress     = 0;
            int stepprogress = 0;

            // Go for all the sidedefs
            foreach (Sidedef sd in General.Map.Map.Sidedefs)
            {
                bool ignoreuppertexture  = false;
                bool ignoremiddletexture = false;
                bool ignorelowertexture  = false;

                // Some actions, like transfer heights, use special non-existing texture names for effects. Allow those to be ignored
                if (sd.Line.Action != 0)
                {
                    LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(sd.Line.Action);
                    ignoreuppertexture  = info.ErrorCheckerExemptions.IgnoreUpperTexture;
                    ignoremiddletexture = info.ErrorCheckerExemptions.IgnoreMiddleTexture;
                    ignorelowertexture  = info.ErrorCheckerExemptions.IgnoreLowerTexture;
                }

                // Check upper texture
                if (!ignoreuppertexture && sd.LongHighTexture != MapSet.EmptyLongName && !General.Map.Data.GetTextureExists(sd.LongHighTexture))
                {
                    SubmitResult(new ResultUnknownTexture(sd, SidedefPart.Upper));
                }

                // Check middle texture
                if (!ignoremiddletexture && sd.LongMiddleTexture != MapSet.EmptyLongName && !General.Map.Data.GetTextureExists(sd.LongMiddleTexture))
                {
                    SubmitResult(new ResultUnknownTexture(sd, SidedefPart.Middle));
                }

                // Check lower texture
                if (!ignorelowertexture && sd.LongLowTexture != MapSet.EmptyLongName && !General.Map.Data.GetTextureExists(sd.LongLowTexture))
                {
                    SubmitResult(new ResultUnknownTexture(sd, SidedefPart.Lower));
                }

                // Handle thread interruption
                try { Thread.Sleep(0); }
                catch (ThreadInterruptedException) { return; }

                // We are making progress!
                if ((++progress / PROGRESS_STEP) > stepprogress)
                {
                    stepprogress = (progress / PROGRESS_STEP);
                    AddProgress(1);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Checks if there's an association between the element and a Thing
        /// </summary>
        /// <param name="thing">Thing to check the association against</param>
        /// <returns>true if the Thing and the element are associated, false if not</returns>
        private bool IsAssociatedToThing(Thing thing)
        {
            // Get the thing type info
            ThingTypeInfo ti = General.Map.Data.GetThingInfoEx(thing.Type);

            // Known action on this thing?
            if ((thing.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(thing.Action))
            {
                //Do not draw the association if this is a child link.
                //  This prevents a reverse link to a thing via an argument, when it should be a direct tag-to-tag link instead.
                if (ti != null && directlinktype < 0 && directlinktype != -thing.Type)
                {
                    return(false);
                }

                LinedefActionInfo action = General.Map.Config.LinedefActions[thing.Action];
                if (((action.Args[0].Type == (int)type) && (tags.Contains(thing.Args[0]))) ||
                    ((action.Args[1].Type == (int)type) && (tags.Contains(thing.Args[1]))) ||
                    ((action.Args[2].Type == (int)type) && (tags.Contains(thing.Args[2]))) ||
                    ((action.Args[3].Type == (int)type) && (tags.Contains(thing.Args[3]))) ||
                    ((action.Args[4].Type == (int)type) && (tags.Contains(thing.Args[4]))))
                {
                    return(true);
                }

                //If there is a link setup on this thing, and it matches the association, then draw a direct link to any matching tag
                if (ti != null && directlinktype == thing.Type && tags.Contains(thing.Tag))
                {
                    return(true);
                }
            }
            //mxd. Thing action on this thing?
            else if (thing.Action == 0)
            {
                // Gets the association, unless it is a child link.
                // This prevents a reverse link to a thing via an argument, when it should be a direct tag-to-tag link instead.
                if (ti != null && directlinktype >= 0 && Math.Abs(directlinktype) != thing.Type)
                {
                    if (((ti.Args[0].Type == (int)type) && (tags.Contains(thing.Args[0]))) ||
                        ((ti.Args[1].Type == (int)type) && (tags.Contains(thing.Args[1]))) ||
                        ((ti.Args[2].Type == (int)type) && (tags.Contains(thing.Args[2]))) ||
                        ((ti.Args[3].Type == (int)type) && (tags.Contains(thing.Args[3]))) ||
                        ((ti.Args[4].Type == (int)type) && (tags.Contains(thing.Args[4]))))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #6
0
        // This renders the associated things with the indication color
        public static void RenderReverseAssociations(IRenderer2D renderer, Association asso, List <Line3D> eventlines)
        {
            // Tag must be above zero
            if (General.GetByIndex(asso.Tags, 0) < 1)
            {
                return;
            }

            // Things
            foreach (Thing t in General.Map.Map.Things)
            {
                // Known action on this thing?
                if ((t.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(t.Action))
                {
                    LinedefActionInfo action = General.Map.Config.LinedefActions[t.Action];
                    if (((action.Args[0].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[0]))) ||
                        ((action.Args[1].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[1]))) ||
                        ((action.Args[2].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[2]))) ||
                        ((action.Args[3].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[3]))) ||
                        ((action.Args[4].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[4]))))
                    {
                        renderer.RenderThing(t, General.Colors.Indication, General.Settings.ActiveThingsAlpha);
                        if (General.Settings.GZShowEventLines)
                        {
                            eventlines.Add(new Line3D(t.Position, asso.Center));                                                           //mxd
                        }
                    }
                }
                //mxd. Thing action on this thing?
                else if (t.Action == 0)
                {
                    ThingTypeInfo ti = General.Map.Data.GetThingInfoEx(t.Type);
                    if (ti != null)
                    {
                        if (((ti.Args[0].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[0]))) ||
                            ((ti.Args[1].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[1]))) ||
                            ((ti.Args[2].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[2]))) ||
                            ((ti.Args[3].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[3]))) ||
                            ((ti.Args[4].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[4]))))
                        {
                            renderer.RenderThing(t, General.Colors.Indication, General.Settings.ActiveThingsAlpha);
                            if (General.Settings.GZShowEventLines)
                            {
                                eventlines.Add(new Line3D(t.Position, asso.Center));
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        // This renders the associated sectors/linedefs with the indication color
        public static void PlotReverseAssociations(IRenderer2D renderer, Association asso, List <Line3D> eventlines)
        {
            // Tag must be above zero
            if (General.GetByIndex(asso.Tags, 0) < 1)
            {
                return;
            }

            // Doom style referencing to sectors?
            if (General.Map.Config.LineTagIndicatesSectors && (asso.Type == UniversalType.SectorTag))
            {
                // Linedefs
                foreach (Linedef l in General.Map.Map.Linedefs)
                {
                    // Any action on this line?
                    if (l.Action <= 0 || !asso.Tags.Overlaps(l.Tags))
                    {
                        continue;
                    }
                    renderer.PlotLinedef(l, General.Colors.Indication);
                    if (General.Settings.GZShowEventLines)
                    {
                        eventlines.Add(new Line3D(l.GetCenterPoint(), asso.Center));                                                       //mxd
                    }
                }
            }

            // Linedefs
            foreach (Linedef l in General.Map.Map.Linedefs)
            {
                // Known action on this line?
                if ((l.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(l.Action))
                {
                    LinedefActionInfo action = General.Map.Config.LinedefActions[l.Action];
                    if (((action.Args[0].Type == (int)asso.Type) && (asso.Tags.Contains(l.Args[0]))) ||
                        ((action.Args[1].Type == (int)asso.Type) && (asso.Tags.Contains(l.Args[1]))) ||
                        ((action.Args[2].Type == (int)asso.Type) && (asso.Tags.Contains(l.Args[2]))) ||
                        ((action.Args[3].Type == (int)asso.Type) && (asso.Tags.Contains(l.Args[3]))) ||
                        ((action.Args[4].Type == (int)asso.Type) && (asso.Tags.Contains(l.Args[4]))))
                    {
                        renderer.PlotLinedef(l, General.Colors.Indication);
                        if (General.Settings.GZShowEventLines)
                        {
                            eventlines.Add(new Line3D(l.GetCenterPoint(), asso.Center));                                                           //mxd
                        }
                    }
                }
            }
        }
예제 #8
0
        // This is called to perform a search (and replace)
        // Returns a list of items to show in the results list
        // replacewith is null when not replacing
        public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
        {
            List <FindReplaceObject> objs = new List <FindReplaceObject>();

            // Where to search?
            ICollection <Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;

            // Go for all linedefs
            foreach (Linedef l in list)
            {
                bool match = true;

                // Parse the value string...
                foreach (string s in value.Split(','))
                {
                    string str = s.Trim();

                    // ... and check if the flags don't match
                    if (General.Map.Config.LinedefFlags.ContainsKey(str) && !l.IsFlagSet(str))
                    {
                        match = false;
                        break;
                    }
                }

                // Flags matches?
                if (match)
                {
                    // Add to list
                    LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
                    if (!info.IsNull)
                    {
                        objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
                    }
                    else
                    {
                        objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
                    }
                }
            }

            return(objs.ToArray());
        }
예제 #9
0
        //mxd
        private void FilterActions(string text)
        {
            List <TreeNode>  filterednodes = new List <TreeNode>();
            HashSet <string> added         = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            // First add nodes, which titles start with given text
            foreach (TreeNode n in allNodes)
            {
                foreach (TreeNode cn in n.Nodes)
                {
                    LinedefActionInfo ai = cn.Tag as LinedefActionInfo;
                    if (ai != null && ai.Title.ToUpperInvariant().StartsWith(text))
                    {
                        filterednodes.Add(cn);
                        added.Add(ai.Title);
                    }
                }
            }

            // Then add nodes, which titles contain given text
            foreach (TreeNode n in allNodes)
            {
                foreach (TreeNode cn in n.Nodes)
                {
                    LinedefActionInfo ai = cn.Tag as LinedefActionInfo;
                    if (ai != null && !added.Contains(ai.Title) && ai.Title.ToUpperInvariant().Contains(text))
                    {
                        filterednodes.Add(cn);
                    }
                }
            }

            actions.BeginUpdate();
            actions.Nodes.Clear();
            actions.ShowLines = false;
            actions.Nodes.AddRange(filterednodes.ToArray());
            actions.EndUpdate();
        }
예제 #10
0
        // This renders the associated things with the indication color
        public void RenderReverseAssociations(IRenderer2D renderer, Association asso)
        {
            // Tag must be above zero
            if (asso.tag <= 0)
            {
                return;
            }

            // Things
            foreach (Thing t in General.Map.Map.Things)
            {
                // Known action on this thing?
                if ((t.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(t.Action))
                {
                    LinedefActionInfo action = General.Map.Config.LinedefActions[t.Action];
                    if ((action.Args[0].Type == (int)asso.type) && (t.Args[0] == asso.tag))
                    {
                        renderer.RenderThing(t, General.Colors.Indication, 1.0f);
                    }
                    if ((action.Args[1].Type == (int)asso.type) && (t.Args[1] == asso.tag))
                    {
                        renderer.RenderThing(t, General.Colors.Indication, 1.0f);
                    }
                    if ((action.Args[2].Type == (int)asso.type) && (t.Args[2] == asso.tag))
                    {
                        renderer.RenderThing(t, General.Colors.Indication, 1.0f);
                    }
                    if ((action.Args[3].Type == (int)asso.type) && (t.Args[3] == asso.tag))
                    {
                        renderer.RenderThing(t, General.Colors.Indication, 1.0f);
                    }
                    if ((action.Args[4].Type == (int)asso.type) && (t.Args[4] == asso.tag))
                    {
                        renderer.RenderThing(t, General.Colors.Indication, 1.0f);
                    }
                }
            }
        }
예제 #11
0
        // This is called to perform a search (and replace)
        // Returns a list of items to show in the results list
        // replacewith is null when not replacing
        public override FindReplaceObject[] Find(string value, bool withinselection, bool replace, string replacewith, bool keepselection)
        {
            List <FindReplaceObject> objs = new List <FindReplaceObject>();

            // Interpret the replacement
            int replacetag = 0;

            if (replace)
            {
                // 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 > 255)
                {
                    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
            int tag;

            if (int.TryParse(value, out tag))
            {
                // Where to search?
                ICollection <Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;

                // Go for all linedefs
                foreach (Linedef l in list)
                {
                    bool addline = false;

                    LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
                    if (info.IsKnown && !info.IsNull)
                    {
                        // Go for all args
                        for (int i = 0; i < Linedef.NUM_ARGS; i++)
                        {
                            // Argument type matches?
                            if (info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.ThingTag))
                            {
                                if (l.Args[i] == tag)
                                {
                                    // Replace
                                    if (replace)
                                    {
                                        l.Args[i] = replacetag;
                                    }
                                    addline = true;
                                }
                            }
                        }
                    }

                    if (addline)
                    {
                        // Add to list
                        if (!info.IsNull)
                        {
                            objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
                        }
                        else
                        {
                            objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
                        }
                    }
                }
            }

            return(objs.ToArray());
        }
예제 #12
0
        /// <summary>
        /// Returns a string that contains the description of the action and its arguments, based on the given Linedef or Thing
        /// </summary>
        /// <param name="se">An instance of Thing or Linedef</param>
        /// <returns>String that contains the description of the action and its arguments for a given Linedef or Thing</returns>
        private string GetActionDescription(SelectableElement se)
        {
            int action = 0;

            int[] actionargs = new int[5];

            if (se is Thing)
            {
                action     = ((Thing)se).Action;
                actionargs = ((Thing)se).Args;
            }
            else if (se is Linedef)
            {
                action     = ((Linedef)se).Action;
                actionargs = ((Linedef)se).Args;
            }

            if (action > 0)
            {
                LinedefActionInfo lai            = General.Map.Config.GetLinedefActionInfo(action);
                List <string>     argdescription = new List <string>();

                string description = lai.Index + ": " + lai.Title;

                // Label style: only action, or if the element can't have any parameters
                if (BuilderPlug.Me.EventLineLabelStyle == 0 || General.Map.Config.LineTagIndicatesSectors)
                {
                    return(description);
                }

                for (int i = 0; i < 5; i++)
                {
                    if (lai.Args[i].Used)
                    {
                        string argstring = "";

                        if (BuilderPlug.Me.EventLineLabelStyle == 2)                        // Label style: full arguments
                        {
                            argstring = lai.Args[i].Title + ": ";
                        }

                        EnumItem ei = lai.Args[i].Enum.GetByEnumIndex(actionargs[i].ToString());

                        if (ei != null && BuilderPlug.Me.EventLineLabelStyle == 2)                         // Label style: full arguments
                        {
                            argstring += ei.ToString();
                        }
                        else                         // Argument has no EnumItem or label style: short arguments
                        {
                            argstring += actionargs[i].ToString();
                        }

                        argdescription.Add(argstring);
                    }
                }

                description += " (" + string.Join(", ", argdescription) + ")";

                return(description);
            }

            return(null);
        }
예제 #13
0
        // This is called to perform a search (and replace)
        // Returns a list of items to show in the results list
        // replacewith is null when not replacing
        public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
        {
            List <FindReplaceObject> objs = new List <FindReplaceObject>();

            // Interpret the replacement
            int replaceaction = 0;

            if (replacewith != null)
            {
                // 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
            int action = 0;

            if (int.TryParse(value, out action))
            {
                // Where to search?
                ICollection <Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;

                // Go for all linedefs
                foreach (Linedef l in list)
                {
                    // Action matches?
                    if (l.Action == action)
                    {
                        // Replace
                        if (replacewith != null)
                        {
                            l.Action = replaceaction;
                        }

                        // Add to list
                        LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
                        if (!info.IsNull)
                        {
                            objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
                        }
                        else
                        {
                            objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
                        }
                    }
                }
            }

            return(objs.ToArray());
        }
예제 #14
0
        /// <summary>
        /// Gets a dictionary of sector tags, linedef tags, and thing tags, grouped by their type, that the map element is referencing
        /// </summary>
        /// <returns>Dictionary of sector tags, linedef tags, and thing tags that the map element is referencing</returns>
        private Dictionary <int, HashSet <int> > GetTagsByType()
        {
            LinedefActionInfo action = null;

            int[] actionargs = new int[5];
            Dictionary <int, HashSet <int> > actiontags = new Dictionary <int, HashSet <int> >();

            // Get the action and its arguments from a linedef or a thing, if they have them
            if (element is Linedef)
            {
                Linedef ld = element as Linedef;

                if (ld.Action > 0 && General.Map.Config.LinedefActions.ContainsKey(ld.Action))
                {
                    action = General.Map.Config.LinedefActions[ld.Action];
                }

                actionargs = ld.Args;
            }
            else if (element is Thing)
            {
                Thing t = element as Thing;

                if (t.Action > 0 && General.Map.Config.LinedefActions.ContainsKey(t.Action))
                {
                    action = General.Map.Config.LinedefActions[t.Action];
                }

                actionargs = t.Args;
            }
            else             // element is a Sector
            {
                return(actiontags);
            }

            if (action != null)
            {
                // Collect what map element the action arguments are referencing. Ignore the argument if it's 0, so that they
                // are not associated to everything untagged
                for (int i = 0; i < Linedef.NUM_ARGS; i++)
                {
                    if ((action.Args[i].Type == (int)UniversalType.SectorTag ||
                         action.Args[i].Type == (int)UniversalType.LinedefTag ||
                         action.Args[i].Type == (int)UniversalType.ThingTag) &&
                        actionargs[i] > 0)
                    {
                        if (!actiontags.ContainsKey(action.Args[i].Type))
                        {
                            actiontags[action.Args[i].Type] = new HashSet <int>();
                        }

                        actiontags[action.Args[i].Type].Add(actionargs[i]);
                    }
                }
            }
            else if (element is Thing && directlinktype >= 0 && Math.Abs(directlinktype) != ((Thing)element).Type)
            {
                // The direct link shenanigans if the thing doesn't have an action, but still reference something through
                // the action parameters
                Thing         t  = element as Thing;
                ThingTypeInfo ti = General.Map.Data.GetThingInfoEx(t.Type);

                if (ti != null && directlinktype >= 0 && Math.Abs(directlinktype) != t.Type)
                {
                    for (int i = 0; i < Linedef.NUM_ARGS; i++)
                    {
                        if ((ti.Args[i].Type == (int)UniversalType.SectorTag ||
                             ti.Args[i].Type == (int)UniversalType.LinedefTag ||
                             ti.Args[i].Type == (int)UniversalType.ThingTag))
                        {
                            if (!actiontags.ContainsKey(ti.Args[i].Type))
                            {
                                actiontags[ti.Args[i].Type] = new HashSet <int>();
                            }

                            actiontags[ti.Args[i].Type].Add(actionargs[i]);
                        }
                    }
                }
            }

            return(actiontags);
        }
예제 #15
0
        // This shows the info
        public void ShowInfo(Linedef l, Sidedef highlightside)
        {
            string peggedness;

            // Show/hide stuff depending on format
            if (!General.Map.FormatInterface.HasActionArgs)
            {
                arglbl1.Visible = false;
                arglbl2.Visible = false;
                arglbl3.Visible = false;
                arglbl4.Visible = false;
                arglbl5.Visible = false;
                arg1.Visible    = false;
                arg2.Visible    = false;
                arg3.Visible    = false;
                arg4.Visible    = false;
                arg5.Visible    = false;
                infopanel.Width = doomformatwidth;
            }
            else
            {
                arglbl1.Visible = true;
                arglbl2.Visible = true;
                arglbl3.Visible = true;
                arglbl4.Visible = true;
                arglbl5.Visible = true;
                arg1.Visible    = true;
                arg2.Visible    = true;
                arg3.Visible    = true;
                arg4.Visible    = true;
                arg5.Visible    = true;
                infopanel.Width = hexenformatwidth;
            }

            //mxd. Hide activation or tag and rearrange labels
            if (!General.Map.FormatInterface.HasBuiltInActivations && General.Map.FormatInterface.HasNumericLinedefActivations)            //Hexen map format?
            {
                activation.Visible      = true;
                activationlabel.Text    = "Activation:";
                activationlabel.Visible = true;
                taglabel.Visible        = false;
                tag.Visible             = false;

                //set activation
                foreach (LinedefActivateInfo ai in General.Map.Config.LinedefActivates)
                {
                    if (l.Activate == ai.Index)
                    {
                        activation.Text = ai.Title;
                        break;
                    }
                }

                activation.Enabled      = (l.Activate != 0 || l.Action != 0);            //mxd
                activationlabel.Enabled = (l.Activate != 0 || l.Action != 0);            //mxd
            }
            else
            {
                if (General.Map.UDMF)
                {
                    // Hijack activation labels to show lock numer...
                    activationlabel.Text    = "Lock:";
                    activationlabel.Visible = true;
                    activation.Visible      = true;

                    int locknum = l.Fields.GetValue("locknumber", 0);
                    if (locknum != 0)
                    {
                        activationlabel.Enabled = true;
                        activation.Enabled      = true;

                        if (General.Map.Config.Enums.ContainsKey("keys"))
                        {
                            foreach (EnumItem item in General.Map.Config.Enums["keys"])
                            {
                                if (item.GetIntValue() == locknum)
                                {
                                    activation.Text = locknum + " - " + item.Title;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            activation.Text = locknum.ToString();
                        }
                    }
                    else
                    {
                        activationlabel.Enabled = false;
                        activation.Enabled      = false;
                        activation.Text         = "None";
                    }
                }
                else
                {
                    // Should be Doom map format
                    activationlabel.Visible = false;
                    activation.Visible      = false;
                }

                taglabel.Visible = true;
                tag.Visible      = true;

                //mxd. Set tag(s)
                if (l.Tags.Count > 1)
                {
                    string[] tags = new string[l.Tags.Count];
                    for (int i = 0; i < l.Tags.Count; i++)
                    {
                        tags[i] = l.Tags[i].ToString();
                    }
                    tag.Text         = string.Join(", ", tags);
                    tag.Enabled      = true;
                    taglabel.Enabled = true;
                    taglabel.Text    = "Tags:";
                }
                else
                {
                    tag.Text         = l.Tag + (General.Map.Options.TagLabels.ContainsKey(l.Tag) ? " - " + General.Map.Options.TagLabels[l.Tag] : string.Empty);
                    tag.Enabled      = (l.Tag != 0);
                    taglabel.Enabled = (l.Tag != 0);
                    taglabel.Text    = "Tag:";
                }
            }

            // Get line action information
            LinedefActionInfo act = General.Map.Config.GetLinedefActionInfo(l.Action);

            // Determine peggedness
            bool upperunpegged = l.IsFlagSet(General.Map.Config.UpperUnpeggedFlag);
            bool lowerunpegged = l.IsFlagSet(General.Map.Config.LowerUnpeggedFlag);

            if (upperunpegged && lowerunpegged)
            {
                peggedness = "Upper & Lower";
            }
            else if (upperunpegged)
            {
                peggedness = "Upper";
            }
            else if (lowerunpegged)
            {
                peggedness = "Lower";
            }
            else
            {
                peggedness = "None";
            }

            // Linedef info
#if DEBUG
            infopanel.Text = " Linedef " + l.Index + " (vert. " + l.Start.Index + " - vert. " + l.End.Index + ") ";
#else
            infopanel.Text = " Linedef " + l.Index + " ";
#endif
            action.Text         = act.ToString();
            length.Text         = l.Length.ToString("0.##");
            angle.Text          = l.AngleDeg + "\u00B0";
            unpegged.Text       = peggedness;
            unpegged.Enabled    = (peggedness != "None");          //mxd
            peglabel.Enabled    = (peggedness != "None");          //mxd
            action.Enabled      = (act.Index != 0);
            actionlabel.Enabled = (act.Index != 0);

            //mxd. ACS script argument names
            bool       isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, l.Action) != -1);
            bool       isarg0str   = (General.Map.UDMF && l.Fields.ContainsKey("arg0str"));
            string     arg0str     = isarg0str ? l.Fields.GetValue("arg0str", string.Empty) : string.Empty;
            ScriptItem scriptitem  = null;

            //mxd. Set default label colors
            arg1.ForeColor    = SystemColors.ControlText;
            arglbl1.ForeColor = SystemColors.ControlText;

            // Named script?
            if (isacsscript && isarg0str && General.Map.NamedScripts.ContainsKey(arg0str.ToLowerInvariant()))
            {
                scriptitem = General.Map.NamedScripts[arg0str.ToLowerInvariant()];
            }
            // Script number?
            else if (isacsscript && General.Map.NumberedScripts.ContainsKey(l.Args[0]))
            {
                scriptitem = General.Map.NumberedScripts[l.Args[0]];
                arg0str    = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString());
            }

            // Apply script args?
            Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 };
            Label[] args      = { arg1, arg2, arg3, arg4, arg5 };

            if (scriptitem != null)
            {
                int      first;
                string[] argnames = scriptitem.GetArgumentsDescriptions(l.Action, out first);
                for (int i = 0; i < first; i++)
                {
                    arglabels[i].Text    = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":";
                    arglabels[i].Enabled = act.Args[i].Used;
                    args[i].Enabled      = act.Args[i].Used;
                }

                for (int i = first; i < argnames.Length; i++)
                {
                    if (!string.IsNullOrEmpty(argnames[i]))
                    {
                        arglabels[i].Text    = argnames[i] + ":";
                        arglabels[i].Enabled = true;
                        args[i].Enabled      = true;
                    }
                    else
                    {
                        arglabels[i].Text    = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":";
                        arglabels[i].Enabled = act.Args[i].Used;
                        args[i].Enabled      = act.Args[i].Used;
                    }
                }
            }
            else
            {
                for (int i = 0; i < act.Args.Length; i++)
                {
                    arglabels[i].Text    = (isarg0str ? act.Args[i].TitleStr : act.Args[i].Title) + ":";
                    arglabels[i].Enabled = act.Args[i].Used;
                    args[i].Enabled      = act.Args[i].Used;
                }

                // Special cases: unknown script name/index
                if (isacsscript)
                {
                    arglbl1.Text      = "Unknown script " + (isarg0str ? "name" : "number") + ":";
                    arg1.ForeColor    = Color.DarkRed;
                    arglbl1.ForeColor = Color.DarkRed;
                }
            }

            //mxd. Set argument value and label
            if (isarg0str)
            {
                arg1.Text = arg0str;
            }
            else
            {
                SetArgumentText(act.Args[0], arg1, l.Args[0]);
            }
            SetArgumentText(act.Args[1], arg2, l.Args[1]);
            SetArgumentText(act.Args[2], arg3, l.Args[2]);
            SetArgumentText(act.Args[3], arg4, l.Args[3]);
            SetArgumentText(act.Args[4], arg5, l.Args[4]);

            // Front side available?
            if (l.Front != null)
            {
                //mxd. Extended info shown?
                bool hasTopFields    = false;
                bool hasMiddleFields = false;
                bool hasBottomFields = false;

                //mxd. Highlight this side?
                bool highlight = (l.Front == highlightside);
                frontpanel.ForeColor = (highlight ? SystemColors.HotTrack : SystemColors.WindowText);                 //mxd

                // Show sidedef info
                frontpanel.Visible = true;                 //mxd
                frontpanel.Text    = " Front Sidedef " + l.Front.Index;

                //mxd
                if (General.Map.UDMF)
                {
                    //light
                    frontoffsetlabel.Text = "Front light:";
                    SetUDMFLight(l.Front, frontoffsetlabel, frontoffset, highlight);

                    //global offset, sector index
                    frontpanel.Text += ". Offset " + l.Front.OffsetX + ", " + l.Front.OffsetY + ". Sector " + l.Front.Sector.Index + " ";

                    //sidedef top
                    hasTopFields  = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_top", "offsety_top", 0.0, frontTopUDMFOffsetLabel, frontTopUDMFOffset, highlight);
                    hasTopFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_top", "scaley_top", 1.0, frontTopUDMFScaleLabel, frontTopUDMFScale, highlight);

                    //sidedef middle
                    hasMiddleFields  = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_mid", "offsety_mid", 0.0, frontMidUDMFOffsetLabel, frontMidUDMFOffset, highlight);
                    hasMiddleFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_mid", "scaley_mid", 1.0, frontMidUDMFScaleLabel, frontMidUDMFScale, highlight);

                    //sidedef bottom
                    hasBottomFields  = SetPairedUDMFFieldsLabel(l.Front.Fields, "offsetx_bottom", "offsety_bottom", 0.0, frontBottomUDMFOffsetLabel, frontBottomUDMFOffset, highlight);
                    hasBottomFields |= SetPairedUDMFFieldsLabel(l.Front.Fields, "scalex_bottom", "scaley_bottom", 1.0, frontBottomUDMFScaleLabel, frontBottomUDMFScale, highlight);

                    //visibility
                    frontTopUDMFOffset.Visible      = hasTopFields;
                    frontTopUDMFOffsetLabel.Visible = hasTopFields;
                    frontTopUDMFScale.Visible       = hasTopFields;
                    frontTopUDMFScaleLabel.Visible  = hasTopFields;

                    frontMidUDMFOffset.Visible      = hasMiddleFields;
                    frontMidUDMFOffsetLabel.Visible = hasMiddleFields;
                    frontMidUDMFScale.Visible       = hasMiddleFields;
                    frontMidUDMFScaleLabel.Visible  = hasMiddleFields;

                    frontBottomUDMFOffset.Visible      = hasBottomFields;
                    frontBottomUDMFOffsetLabel.Visible = hasBottomFields;
                    frontBottomUDMFScale.Visible       = hasBottomFields;
                    frontBottomUDMFScaleLabel.Visible  = hasBottomFields;
                }
                else
                {
                    frontoffsetlabel.Text = "Front offset:";
                    if (l.Front.OffsetX != 0 || l.Front.OffsetY != 0)
                    {
                        frontoffset.Text         = l.Front.OffsetX + ", " + l.Front.OffsetY;
                        frontoffsetlabel.Enabled = true;
                        frontoffset.Enabled      = true;

                        frontoffset.ForeColor      = (highlight ? SystemColors.HotTrack : SystemColors.WindowText);
                        frontoffsetlabel.ForeColor = frontoffset.ForeColor;
                    }
                    else
                    {
                        frontoffset.Text         = "--, --";
                        frontoffsetlabel.Enabled = false;
                        frontoffset.Enabled      = false;
                    }

                    //mxd. Sector index
                    frontpanel.Text += ". Sector " + l.Front.Sector.Index + " ";

                    //visibility
                    frontTopUDMFOffsetLabel.Visible = false;
                    frontTopUDMFScaleLabel.Visible  = false;

                    frontMidUDMFOffsetLabel.Visible = false;
                    frontMidUDMFScaleLabel.Visible  = false;

                    frontBottomUDMFOffsetLabel.Visible = false;
                    frontBottomUDMFScaleLabel.Visible  = false;
                }

                //mxd. Set texture names, update panel sizes
                UpdateTexturePanel(panelFrontTop, l.Front.HighTexture, fronthighname, labelTextureFrontTop,
                                   Math.Max(frontTopUDMFOffset.Right, frontTopUDMFScale.Right) + 4, fronthightex,
                                   frontTopUDMFOffsetLabel.Left, hasTopFields, l.Front.HighRequired());

                UpdateTexturePanel(panelFrontMid, l.Front.MiddleTexture, frontmidname, labelTextureFrontMid,
                                   Math.Max(frontMidUDMFOffset.Right, frontMidUDMFScale.Right) + 4, frontmidtex,
                                   frontMidUDMFOffsetLabel.Left, hasMiddleFields, l.Front.MiddleRequired());

                UpdateTexturePanel(panelFrontLow, l.Front.LowTexture, frontlowname, labelTextureFrontBottom,
                                   Math.Max(frontBottomUDMFOffset.Right, frontBottomUDMFScale.Right) + 4, frontlowtex,
                                   frontBottomUDMFOffsetLabel.Left, hasBottomFields, l.Front.LowRequired());

                //mxd. Resize panel
                flowLayoutPanelFront.Width = panelFrontLow.Right;
                frontpanel.Width           = flowLayoutPanelFront.Width + flowLayoutPanelFront.Left * 2 - 4;
            }
            else
            {
                // Show no info
                if (General.Map.UDMF)                //mxd
                {
                    frontoffsetlabel.Text = "Front light:";
                    frontoffset.Text      = "--";
                }
                else
                {
                    frontoffsetlabel.Text = "Front offset:";
                    frontoffset.Text      = "--, --";
                }

                frontoffsetlabel.Enabled = false;
                frontoffset.Enabled      = false;

                fronthightex.BackgroundImage = null;
                frontmidtex.BackgroundImage  = null;
                frontlowtex.BackgroundImage  = null;

                frontpanel.Visible = false;                 //mxd
            }

            // Back size available?
            if (l.Back != null)
            {
                //mxd. Extended info shown?
                bool hasTopFields    = false;
                bool hasMiddleFields = false;
                bool hasBottomFields = false;

                //mxd. Highlight this side?
                bool highlight = l.Back == highlightside;
                backpanel.ForeColor = (highlight ? SystemColors.HotTrack : SystemColors.WindowText);                 //mxd

                // Show sidedef info
                backpanel.Visible = true;                 //mxd
                backpanel.Text    = " Back Sidedef " + l.Back.Index;

                //mxd
                if (General.Map.UDMF)
                {
                    //light
                    backoffsetlabel.Text = "Back light:";
                    SetUDMFLight(l.Back, backoffsetlabel, backoffset, highlight);

                    //global offset, sector index
                    backpanel.Text += ". Offset " + l.Back.OffsetX + ", " + l.Back.OffsetY + ". Sector " + l.Back.Sector.Index + " ";

                    //sidedef top
                    hasTopFields  = SetPairedUDMFFieldsLabel(l.Back.Fields, "offsetx_top", "offsety_top", 0.0, backTopUDMFOffsetLabel, backTopUDMFOffset, highlight);
                    hasTopFields |= SetPairedUDMFFieldsLabel(l.Back.Fields, "scalex_top", "scaley_top", 1.0, backTopUDMFScaleLabel, backTopUDMFScale, highlight);

                    //sidedef middle
                    hasMiddleFields  = SetPairedUDMFFieldsLabel(l.Back.Fields, "offsetx_mid", "offsety_mid", 0.0, backMidUDMFOffsetLabel, backMidUDMFOffset, highlight);
                    hasMiddleFields |= SetPairedUDMFFieldsLabel(l.Back.Fields, "scalex_mid", "scaley_mid", 1.0, backMidUDMFScaleLabel, backMidUDMFScale, highlight);

                    //sidedef bottom
                    hasBottomFields  = SetPairedUDMFFieldsLabel(l.Back.Fields, "offsetx_bottom", "offsety_bottom", 0.0, backBottomUDMFOffsetLabel, backBottomUDMFOffset, highlight);
                    hasBottomFields |= SetPairedUDMFFieldsLabel(l.Back.Fields, "scalex_bottom", "scaley_bottom", 1.0, backBottomUDMFScaleLabel, backBottomUDMFScale, highlight);

                    //visibility
                    backTopUDMFOffset.Visible      = hasTopFields;
                    backTopUDMFOffsetLabel.Visible = hasTopFields;
                    backTopUDMFScale.Visible       = hasTopFields;
                    backTopUDMFScaleLabel.Visible  = hasTopFields;

                    backMidUDMFOffset.Visible      = hasMiddleFields;
                    backMidUDMFOffsetLabel.Visible = hasMiddleFields;
                    backMidUDMFScale.Visible       = hasMiddleFields;
                    backMidUDMFScaleLabel.Visible  = hasMiddleFields;

                    backBottomUDMFOffset.Visible      = hasBottomFields;
                    backBottomUDMFOffsetLabel.Visible = hasBottomFields;
                    backBottomUDMFScale.Visible       = hasBottomFields;
                    backBottomUDMFScaleLabel.Visible  = hasBottomFields;
                }
                else
                {
                    backoffsetlabel.Text = "Back offset:";
                    if (l.Back.OffsetX != 0 || l.Back.OffsetY != 0)
                    {
                        backoffset.Text         = l.Back.OffsetX + ", " + l.Back.OffsetY;
                        backoffsetlabel.Enabled = true;
                        backoffset.Enabled      = true;

                        backoffset.ForeColor      = (highlight ? SystemColors.HotTrack : SystemColors.WindowText);
                        backoffsetlabel.ForeColor = backoffset.ForeColor;
                    }
                    else
                    {
                        backoffset.Text         = "--, --";
                        backoffsetlabel.Enabled = false;
                        backoffset.Enabled      = false;
                    }

                    // Sector index
                    backpanel.Text += ". Sector " + l.Back.Sector.Index + " ";
                }

                //mxd. Set texture names, update panel sizes
                UpdateTexturePanel(panelBackTop, l.Back.HighTexture, backhighname, labelTextureBackTop,
                                   Math.Max(backTopUDMFOffset.Right, backTopUDMFScale.Right) + 4, backhightex,
                                   backTopUDMFOffsetLabel.Left, hasTopFields, l.Back.HighRequired());

                UpdateTexturePanel(panelBackMid, l.Back.MiddleTexture, backmidname, labelTextureBackMid,
                                   Math.Max(backMidUDMFOffset.Right, backMidUDMFScale.Right) + 4, backmidtex,
                                   backMidUDMFOffsetLabel.Left, hasMiddleFields, l.Back.MiddleRequired());

                UpdateTexturePanel(panelBackLow, l.Back.LowTexture, backlowname, labelTextureBackBottom,
                                   Math.Max(backBottomUDMFOffset.Right, backBottomUDMFScale.Right) + 4, backlowtex,
                                   backBottomUDMFOffsetLabel.Left, hasBottomFields, l.Back.LowRequired());

                //mxd. Resize panel
                flowLayoutPanelBack.Width = panelBackLow.Right;
                backpanel.Width           = flowLayoutPanelBack.Width + flowLayoutPanelBack.Left * 2 - 4;
            }
            else
            {
                // Show no info
                if (General.Map.UDMF)                //mxd
                {
                    backoffsetlabel.Text = "Back light:";
                    backoffset.Text      = "--";
                }
                else
                {
                    backoffsetlabel.Text = "Back offset:";
                    backoffset.Text      = "--, --";
                }

                backoffsetlabel.Enabled = false;
                backoffset.Enabled      = false;

                backhightex.BackgroundImage = null;
                backmidtex.BackgroundImage  = null;
                backlowtex.BackgroundImage  = null;

                backpanel.Visible = false;                 //mxd
            }

            //mxd. Flags and activations
            flags.Items.Clear();

            // Add activations
            foreach (LinedefActivateInfo ai in General.Map.Config.LinedefActivates)
            {
                if (l.Flags.ContainsKey(ai.Key) && l.Flags[ai.Key])
                {
                    flags.Items.Add(new ListViewItem(ai.Title)
                    {
                        Checked = true, ForeColor = SystemColors.HotTrack
                    });
                }
            }

            // And flags
            foreach (KeyValuePair <string, string> group in General.Map.Config.LinedefFlags)
            {
                if (l.Flags.ContainsKey(group.Key) && l.Flags[group.Key])
                {
                    flags.Items.Add(new ListViewItem(group.Value)
                    {
                        Checked = true
                    });
                }
            }

            // And front flags
            if (l.Front != null)
            {
                foreach (KeyValuePair <string, string> group in General.Map.Config.SidedefFlags)
                {
                    if (l.Front.Flags.ContainsKey(group.Key) && l.Front.Flags[group.Key])
                    {
                        flags.Items.Add(new ListViewItem("Front: " + group.Value)
                        {
                            Checked = true
                        });
                    }
                }
            }

            // And back flags
            if (l.Back != null)
            {
                foreach (KeyValuePair <string, string> group in General.Map.Config.SidedefFlags)
                {
                    if (l.Back.Flags.ContainsKey(group.Key) && l.Back.Flags[group.Key])
                    {
                        flags.Items.Add(new ListViewItem("Back: " + group.Value)
                        {
                            Checked = true
                        });
                    }
                }
            }

            //mxd. Flags panel visibility and size
            flagsPanel.Visible = (flags.Items.Count > 0);
            if (flags.Items.Count > 0)
            {
                Rectangle rect           = flags.GetItemRect(0);
                int       itemspercolumn = 1;

                // Check how many items per column we have...
                for (int i = 1; i < flags.Items.Count; i++)
                {
                    if (flags.GetItemRect(i).X != rect.X)
                    {
                        break;
                    }
                    itemspercolumn++;
                }

                flags.Width      = rect.Width * (int)Math.Ceiling(flags.Items.Count / (float)itemspercolumn);
                flagsPanel.Width = flags.Width + flags.Left * 2;
            }

            // Show the whole thing
            this.Show();
            //this.Update(); // ano - don't think this is needed, and is slow
        }
예제 #16
0
        // This highlights a new item
        protected void Highlight(Linedef l)
        {
            bool completeredraw      = false;
            LinedefActionInfo action = null;

            // Often we can get away by simply undrawing the previous
            // highlight and drawing the new highlight. But if associations
            // are or were drawn we need to redraw the entire display.

            // Previous association highlights something?
            if ((highlighted != null) && (highlighted.Tag > 0))
            {
                completeredraw = true;
            }

            // Set highlight association
            if (l != null)
            {
                highlightasso.Set(l.Tag, UniversalType.LinedefTag);
            }
            else
            {
                highlightasso.Set(0, 0);
            }

            // New association highlights something?
            if ((l != null) && (l.Tag > 0))
            {
                completeredraw = true;
            }

            // Use the line tag to highlight sectors (Doom style)
            if (General.Map.Config.LineTagIndicatesSectors)
            {
                if (l != null)
                {
                    association[0].Set(l.Tag, UniversalType.SectorTag);
                    if (General.Map.FormatInterface.InDoom64Mode)    // villsa
                    {
                        association[1].Set(l.Tag, UniversalType.ThingTag);
                    }
                }
                else
                {
                    association[0].Set(0, 0);
                }
            }
            else
            {
                if (l != null)
                {
                    // Check if we can find the linedefs action
                    if ((l.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(l.Action))
                    {
                        action = General.Map.Config.LinedefActions[l.Action];
                    }
                }

                // Determine linedef associations
                for (int i = 0; i < Linedef.NUM_ARGS; i++)
                {
                    // Previous association highlights something?
                    if ((association[i].type == UniversalType.SectorTag) ||
                        (association[i].type == UniversalType.LinedefTag) ||
                        (association[i].type == UniversalType.ThingTag))
                    {
                        completeredraw = true;
                    }

                    // Make new association
                    if (action != null)
                    {
                        association[i].Set(l.Args[i], action.Args[i].Type);
                    }
                    else
                    {
                        association[i].Set(0, 0);
                    }

                    // New association highlights something?
                    if ((association[i].type == UniversalType.SectorTag) ||
                        (association[i].type == UniversalType.LinedefTag) ||
                        (association[i].type == UniversalType.ThingTag))
                    {
                        completeredraw = true;
                    }
                }
            }

            // If we're changing associations, then we
            // need to redraw the entire display
            if (completeredraw)
            {
                // Set new highlight and redraw completely
                highlighted = l;
                General.Interface.RedrawDisplay();
            }
            else
            {
                // Update display
                if (renderer.StartPlotter(false))
                {
                    // Undraw previous highlight
                    if ((highlighted != null) && !highlighted.IsDisposed)
                    {
                        renderer.PlotLinedef(highlighted, renderer.DetermineLinedefColor(highlighted));
                        renderer.PlotVertex(highlighted.Start, renderer.DetermineVertexColor(highlighted.Start));
                        renderer.PlotVertex(highlighted.End, renderer.DetermineVertexColor(highlighted.End));
                    }

                    // Set new highlight
                    highlighted = l;

                    // Render highlighted item
                    if ((highlighted != null) && !highlighted.IsDisposed)
                    {
                        renderer.PlotLinedef(highlighted, General.Colors.Highlight);
                        renderer.PlotVertex(highlighted.Start, renderer.DetermineVertexColor(highlighted.Start));
                        renderer.PlotVertex(highlighted.End, renderer.DetermineVertexColor(highlighted.End));
                    }

                    // Done
                    renderer.Finish();
                    renderer.Present();
                }
            }

            // Show highlight info
            if ((highlighted != null) && !highlighted.IsDisposed)
            {
                General.Interface.ShowLinedefInfo(highlighted);
            }
            else
            {
                General.Interface.HideInfo();
            }
        }
예제 #17
0
        // This shows the info
        public void ShowInfo(Thing t)
        {
            // Show/hide stuff depending on format
            bool hasArgs = General.Map.FormatInterface.HasActionArgs;

            arglbl1.Visible = hasArgs;
            arglbl2.Visible = hasArgs;
            arglbl3.Visible = hasArgs;
            arglbl4.Visible = hasArgs;
            arglbl5.Visible = hasArgs;
            arg1.Visible    = hasArgs;
            arg2.Visible    = hasArgs;
            arg3.Visible    = hasArgs;
            arg4.Visible    = hasArgs;
            arg5.Visible    = hasArgs;
            infopanel.Width = (hasArgs ? hexenformatwidth : doomformatwidth);

            //mxd
            action.Visible      = General.Map.FormatInterface.HasThingAction;
            labelaction.Visible = General.Map.FormatInterface.HasThingAction;

            // Move panel
            spritepanel.Left = infopanel.Left + infopanel.Width + infopanel.Margin.Right + spritepanel.Margin.Left;
            flagsPanel.Left  = spritepanel.Left + spritepanel.Width + spritepanel.Margin.Right + flagsPanel.Margin.Left;            //mxd

            // Lookup thing info
            ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);

            // Get thing action information
            LinedefActionInfo act;

            if (General.Map.Config.LinedefActions.ContainsKey(t.Action))
            {
                act = General.Map.Config.LinedefActions[t.Action];
            }
            else if (t.Action == 0)
            {
                act = new LinedefActionInfo(0, "None", true, false);
            }
            else
            {
                act = new LinedefActionInfo(t.Action, "Unknown", false, false);
            }
            string actioninfo = act.ToString();

            // Determine z info to show
            t.DetermineSector();
            string zinfo;

            if (ti.AbsoluteZ || t.Sector == null)
            {
                zinfo = t.Position.z.ToString(CultureInfo.InvariantCulture) + " (abs.)";                 //mxd
            }
            else
            {
                // Hangs from ceiling?
                if (ti.Hangs)
                {
                    zinfo = t.Position.z + " (" + ((float)Math.Round(Sector.GetCeilingPlane(t.Sector).GetZ(t.Position) - t.Position.z - ti.Height, General.Map.FormatInterface.VertexDecimals)).ToString(CultureInfo.InvariantCulture) + ")";                     //mxd
                }
                else
                {
                    zinfo = t.Position.z + " (" + ((float)Math.Round(Sector.GetFloorPlane(t.Sector).GetZ(t.Position) + t.Position.z, General.Map.FormatInterface.VertexDecimals)).ToString(CultureInfo.InvariantCulture) + ")";                     //mxd
                }
            }

            // Thing info
            infopanel.Text = " Thing " + t.Index + " ";
            type.Text      = t.Type + " - " + ti.Title;
            if (ti.IsObsolete)
            {
                type.Text += " - OBSOLETE";                           //mxd
            }
            action.Text = actioninfo;
            bool displayclassname = !string.IsNullOrEmpty(ti.ClassName) && !ti.ClassName.StartsWith("$"); //mxd

            labelclass.Enabled = displayclassname;                                                        //mxd
            classname.Enabled  = displayclassname;                                                        //mxd
            classname.Text     = (displayclassname ? ti.ClassName : "--");                                //mxd
            position.Text      = t.Position.x.ToString(CultureInfo.InvariantCulture) + ", " + t.Position.y.ToString(CultureInfo.InvariantCulture) + ", " + zinfo;
            tag.Text           = t.Tag + (General.Map.Options.TagLabels.ContainsKey(t.Tag) ? " - " + General.Map.Options.TagLabels[t.Tag] : string.Empty);
            angle.Text         = t.AngleDoom + "\u00B0";
            anglecontrol.Angle = t.AngleDoom;
            anglecontrol.Left  = angle.Right + 1;

            // Sprite
            if (ti.Sprite.ToLowerInvariant().StartsWith(DataManager.INTERNAL_PREFIX) && (ti.Sprite.Length > DataManager.INTERNAL_PREFIX.Length))
            {
                spritename.Text = "";
                spritetex.Image = General.Map.Data.GetSpriteImage(ti.Sprite).GetBitmap();
            }
            else if ((ti.Sprite.Length <= 8) && (ti.Sprite.Length > 0))
            {
                spritename.Text = ti.Sprite;
                spritetex.Image = General.Map.Data.GetSpriteImage(ti.Sprite).GetPreview();
            }
            else
            {
                spritename.Text = "";
                spritetex.Image = null;
            }

            // Arguments
            ArgumentInfo[] arginfo = ((t.Action == 0 && ti.Args[0] != null) ? ti.Args : act.Args);             //mxd

            //mxd. ACS script argument names
            bool       isacsscript = (Array.IndexOf(GZGeneral.ACS_SPECIALS, t.Action) != -1);
            bool       isarg0str   = (General.Map.UDMF && t.Fields.ContainsKey("arg0str"));
            string     arg0str     = isarg0str ? t.Fields.GetValue("arg0str", string.Empty) : string.Empty;
            ScriptItem scriptitem  = null;

            //mxd. Set default label colors
            arg1.ForeColor    = SystemColors.ControlText;
            arglbl1.ForeColor = SystemColors.ControlText;

            // Named script?
            if (isacsscript && isarg0str && General.Map.NamedScripts.ContainsKey(arg0str.ToLowerInvariant()))
            {
                scriptitem = General.Map.NamedScripts[arg0str.ToLowerInvariant()];
            }
            // Script number?
            else if (isacsscript && General.Map.NumberedScripts.ContainsKey(t.Args[0]))
            {
                scriptitem = General.Map.NumberedScripts[t.Args[0]];
                arg0str    = (scriptitem.HasCustomName ? scriptitem.Name : scriptitem.Index.ToString());
            }

            // Apply script args?
            Label[] arglabels = { arglbl1, arglbl2, arglbl3, arglbl4, arglbl5 };
            Label[] args      = { arg1, arg2, arg3, arg4, arg5 };

            if (scriptitem != null)
            {
                int      first;
                string[] argnames = scriptitem.GetArgumentsDescriptions(t.Action, out first);
                for (int i = 0; i < first; i++)
                {
                    arglabels[i].Text    = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":";
                    arglabels[i].Enabled = arginfo[i].Used;
                    args[i].Enabled      = arginfo[i].Used;
                }

                for (int i = first; i < argnames.Length; i++)
                {
                    if (!string.IsNullOrEmpty(argnames[i]))
                    {
                        arglabels[i].Text    = argnames[i] + ":";
                        arglabels[i].Enabled = true;
                        args[i].Enabled      = true;
                    }
                    else
                    {
                        arglabels[i].Text    = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":";
                        arglabels[i].Enabled = arginfo[i].Used;
                        args[i].Enabled      = arginfo[i].Used;
                    }
                }
            }
            else
            {
                for (int i = 0; i < arginfo.Length; i++)
                {
                    arglabels[i].Text    = (isarg0str ? arginfo[i].TitleStr : arginfo[i].Title) + ":";
                    arglabels[i].Enabled = arginfo[i].Used;
                    args[i].Enabled      = arginfo[i].Used;
                }

                // Special cases: unknown script name/index
                if (isacsscript)
                {
                    arglbl1.Text      = "Unknown script " + (isarg0str ? "name" : "number") + ":";
                    arg1.ForeColor    = Color.DarkRed;
                    arglbl1.ForeColor = Color.DarkRed;
                }
            }

            //mxd. Set argument value and label
            if (isarg0str)
            {
                arg1.Text = arg0str;
            }
            else
            {
                SetArgumentText(act.Args[0], arg1, t.Args[0]);
            }
            SetArgumentText(arginfo[1], arg2, t.Args[1]);
            SetArgumentText(arginfo[2], arg3, t.Args[2]);
            SetArgumentText(arginfo[3], arg4, t.Args[3]);
            SetArgumentText(arginfo[4], arg5, t.Args[4]);

            //mxd. Flags
            flags.Items.Clear();
            Dictionary <string, string> flagsrename = ti.FlagsRename;

            foreach (KeyValuePair <string, string> group in General.Map.Config.ThingFlags)
            {
                if (t.Flags.ContainsKey(group.Key) && t.Flags[group.Key])
                {
                    ListViewItem lvi = (flagsrename != null && flagsrename.ContainsKey(group.Key))
                                                ? new ListViewItem(flagsrename[group.Key])
                    {
                        ForeColor = SystemColors.HotTrack
                    }
                                                : new ListViewItem(group.Value);
                    lvi.Checked = true;
                    flags.Items.Add(lvi);
                }
            }

            //mxd. Flags panel visibility and size
            flagsPanel.Visible = (flags.Items.Count > 0);
            if (flags.Items.Count > 0)
            {
                Rectangle rect           = flags.GetItemRect(0);
                int       itemspercolumn = 1;

                // Check how many items per column we have...
                for (int i = 1; i < flags.Items.Count; i++)
                {
                    if (flags.GetItemRect(i).X != rect.X)
                    {
                        break;
                    }
                    itemspercolumn++;
                }

                flags.Width      = rect.Width * (int)Math.Ceiling(flags.Items.Count / (float)itemspercolumn);
                flagsPanel.Width = flags.Width + flags.Left * 2;
            }

            // Show the whole thing
            this.Show();
            //this.Update(); // ano - don't think this is needed, and is slow
        }
예제 #18
0
        // This shows the info
        public void ShowInfo(Linedef l)
        {
            TypeHandler th;
            bool        upperunpegged, lowerunpegged;
            string      peggedness;

            // Show/hide stuff depending on format
            if (!General.Map.FormatInterface.HasActionArgs)
            {
                arglbl1.Visible = false;
                arglbl2.Visible = false;
                arglbl3.Visible = false;
                arglbl4.Visible = false;
                arglbl5.Visible = false;
                arg1.Visible    = false;
                arg2.Visible    = false;
                arg3.Visible    = false;
                arg4.Visible    = false;
                arg5.Visible    = false;
                infopanel.Width = doomformatwidth;
            }
            else
            {
                arglbl1.Visible = true;
                arglbl2.Visible = true;
                arglbl3.Visible = true;
                arglbl4.Visible = true;
                arglbl5.Visible = true;
                arg1.Visible    = true;
                arg2.Visible    = true;
                arg3.Visible    = true;
                arg4.Visible    = true;
                arg5.Visible    = true;
                infopanel.Width = hexenformatwidth;
            }

            // Move panels
            frontpanel.Left = infopanel.Left + infopanel.Width + infopanel.Margin.Right + frontpanel.Margin.Left;
            backpanel.Left  = frontpanel.Left + frontpanel.Width + frontpanel.Margin.Right + backpanel.Margin.Left;

            // Get line action information
            LinedefActionInfo act = General.Map.Config.GetLinedefActionInfo(l.Action);

            // Determine peggedness
            upperunpegged = l.IsFlagSet(General.Map.Config.UpperUnpeggedFlag);
            lowerunpegged = l.IsFlagSet(General.Map.Config.LowerUnpeggedFlag);
            if (upperunpegged && lowerunpegged)
            {
                peggedness = "Upper & Lower";
            }
            else if (upperunpegged)
            {
                peggedness = "Upper";
            }
            else if (lowerunpegged)
            {
                peggedness = "Lower";
            }
            else
            {
                peggedness = "None";
            }

            // Linedef info
            infopanel.Text = " Linedef " + l.Index + " ";
            action.Text    = act.ToString();
            length.Text    = l.Length.ToString("0.##");
            angle.Text     = l.AngleDeg.ToString() + "\u00B0";
            tag.Text       = l.Tag.ToString();
            unpegged.Text  = peggedness;

            // Arguments
            arglbl1.Text    = act.Args[0].Title + ":";
            arglbl2.Text    = act.Args[1].Title + ":";
            arglbl3.Text    = act.Args[2].Title + ":";
            arglbl4.Text    = act.Args[3].Title + ":";
            arglbl5.Text    = act.Args[4].Title + ":";
            arglbl1.Enabled = act.Args[0].Used;
            arglbl2.Enabled = act.Args[1].Used;
            arglbl3.Enabled = act.Args[2].Used;
            arglbl4.Enabled = act.Args[3].Used;
            arglbl5.Enabled = act.Args[4].Used;
            arg1.Enabled    = act.Args[0].Used;
            arg2.Enabled    = act.Args[1].Used;
            arg3.Enabled    = act.Args[2].Used;
            arg4.Enabled    = act.Args[3].Used;
            arg5.Enabled    = act.Args[4].Used;
            th = General.Types.GetArgumentHandler(act.Args[0]);
            th.SetValue(l.Args[0]); arg1.Text = th.GetStringValue();
            th = General.Types.GetArgumentHandler(act.Args[1]);
            th.SetValue(l.Args[1]); arg2.Text = th.GetStringValue();
            th = General.Types.GetArgumentHandler(act.Args[2]);
            th.SetValue(l.Args[2]); arg3.Text = th.GetStringValue();
            th = General.Types.GetArgumentHandler(act.Args[3]);
            th.SetValue(l.Args[3]); arg4.Text = th.GetStringValue();
            th = General.Types.GetArgumentHandler(act.Args[4]);
            th.SetValue(l.Args[4]); arg5.Text = th.GetStringValue();

            // Front side available?
            if (l.Front != null)
            {
                // Show sidedef info
                frontpanel.Text     = " Front Sidedef " + l.Front.Index + " ";
                frontsector.Text    = " Sector " + l.Front.Sector.Index;
                frontsector.Visible = true;
                frontoffset.Text    = l.Front.OffsetX + ", " + l.Front.OffsetY;
                fronthighname.Text  = l.Front.HighTexture;
                frontmidname.Text   = l.Front.MiddleTexture;
                frontlowname.Text   = l.Front.LowTexture;
                DisplaySidedefTexture(fronthightex, l.Front.HighTexture, l.Front.HighRequired());
                DisplaySidedefTexture(frontmidtex, l.Front.MiddleTexture, l.Front.MiddleRequired());
                DisplaySidedefTexture(frontlowtex, l.Front.LowTexture, l.Front.LowRequired());
                frontoffsetlabel.Enabled = true;
                frontoffset.Enabled      = true;
                frontpanel.Enabled       = true;
            }
            else
            {
                // Show no info
                frontpanel.Text              = " Front Sidedef ";
                frontsector.Text             = "";
                frontsector.Visible          = false;
                frontoffsetlabel.Enabled     = false;
                frontoffset.Enabled          = false;
                frontpanel.Enabled           = false;
                frontoffset.Text             = "--, --";
                fronthighname.Text           = "";
                frontmidname.Text            = "";
                frontlowname.Text            = "";
                fronthightex.BackgroundImage = null;
                frontmidtex.BackgroundImage  = null;
                frontlowtex.BackgroundImage  = null;
            }

            // Back size available?
            if (l.Back != null)
            {
                // Show sidedef info
                backpanel.Text     = " Back Sidedef " + l.Back.Index + " ";
                backsector.Text    = " Sector " + l.Back.Sector.Index;
                backsector.Visible = true;
                backoffset.Text    = l.Back.OffsetX + ", " + l.Back.OffsetY;
                backhighname.Text  = l.Back.HighTexture;
                backmidname.Text   = l.Back.MiddleTexture;
                backlowname.Text   = l.Back.LowTexture;
                DisplaySidedefTexture(backhightex, l.Back.HighTexture, l.Back.HighRequired());
                DisplaySidedefTexture(backmidtex, l.Back.MiddleTexture, l.Back.MiddleRequired());
                DisplaySidedefTexture(backlowtex, l.Back.LowTexture, l.Back.LowRequired());
                backoffsetlabel.Enabled = true;
                backoffset.Enabled      = true;
                backpanel.Enabled       = true;
            }
            else
            {
                // Show no info
                backpanel.Text              = " Back Sidedef ";
                backsector.Text             = "";
                backsector.Visible          = false;
                backoffsetlabel.Enabled     = false;
                backoffset.Enabled          = false;
                backpanel.Enabled           = false;
                backoffset.Text             = "--, --";
                backhighname.Text           = "";
                backmidname.Text            = "";
                backlowname.Text            = "";
                backhightex.BackgroundImage = null;
                backmidtex.BackgroundImage  = null;
                backlowtex.BackgroundImage  = null;
            }

            // Position labels
            frontsector.Left = frontlowtex.Right - frontsector.Width;
            backsector.Left  = backlowtex.Right - backsector.Width;

            // Show the whole thing
            this.Show();
            this.Update();
        }
예제 #19
0
        // This shows the info
        public void ShowInfo(Linedef l)
        {
            TypeHandler th;
            bool        upperunpegged, lowerunpegged;
            string      peggedness;

            //double starttime = General.stopwatch.Elapsed.TotalMilliseconds;
            SuspendLayout();

            // Show/hide stuff depending on format
            if (!General.Map.FormatInterface.HasActionArgs)
            {
                if (bUsingArgsAlready || bNeedSetup)
                {
                    arglbl1.Visible = false;
                    arglbl2.Visible = false;
                    arglbl3.Visible = false;
                    arglbl4.Visible = false;
                    arglbl5.Visible = false;
                    arg1.Visible    = false;
                    arg2.Visible    = false;
                    arg3.Visible    = false;
                    arg4.Visible    = false;
                    arg5.Visible    = false;

                    tableLayoutPanel1.ColumnStyles[1].Width = 0f;
                    infopanel.Width   = doomformatwidth;
                    bUsingArgsAlready = false;
                }
            }
            else
            {
                if (!bUsingArgsAlready || bNeedSetup)
                {
                    arglbl1.Visible = true;
                    arglbl2.Visible = true;
                    arglbl3.Visible = true;
                    arglbl4.Visible = true;
                    arglbl5.Visible = true;
                    arg1.Visible    = true;
                    arg2.Visible    = true;
                    arg3.Visible    = true;
                    arg4.Visible    = true;
                    arg5.Visible    = true;

                    tableLayoutPanel1.ColumnStyles[1].Width = 37.5f;
                    infopanel.Width   = hexenformatwidth;
                    bUsingArgsAlready = true;
                }
            }

            // Move panels
            frontpanel.Left = infopanel.Left + infopanel.Width + infopanel.Margin.Right + frontpanel.Margin.Left;
            backpanel.Left  = frontpanel.Left + frontpanel.Width + frontpanel.Margin.Right + backpanel.Margin.Left;

            // Get line action information
            LinedefActionInfo act = General.Map.Config.GetLinedefActionInfo(l.Action);

            // Determine peggedness
            upperunpegged = l.IsFlagSet(General.Map.Config.UpperUnpeggedFlag);
            lowerunpegged = l.IsFlagSet(General.Map.Config.LowerUnpeggedFlag);
            if (upperunpegged && lowerunpegged)
            {
                peggedness = "Upper/Lower";
            }
            else if (upperunpegged)
            {
                peggedness = "Upper";
            }
            else if (lowerunpegged)
            {
                peggedness = "Lower";
            }
            else
            {
                peggedness = "None";
            }

            // Linedef info
            sb.Length = 0;
            sb.Append(" Linedef ");
            sb.Append(l.Index);
            sb.Append(" ");
            infopanel.Text = sb.ToString();
            sb.Length      = 0;
            action.Text    = act.ToString();
            length.Text    = l.Length.ToString("0.##");
            sb.Append(l.AngleDeg.ToString());
            sb.Append("\u00B0");
            angle.Text    = sb.ToString();
            sb.Length     = 0;
            tag.Text      = l.Tag.ToString();
            unpegged.Text = peggedness;

            if (bUsingArgsAlready)
            {
                // Arguments
                sb.Append(act.Args[0].Title);
                sb.Append(':');
                arglbl1.Text = sb.ToString();
                sb.Length    = 0;
                sb.Append(act.Args[1].Title);
                sb.Append(':');
                arglbl2.Text = sb.ToString();
                sb.Length    = 0;
                sb.Append(act.Args[2].Title);
                sb.Append(':');
                arglbl3.Text = sb.ToString();
                sb.Length    = 0;
                sb.Append(act.Args[3].Title);
                sb.Append(':');
                arglbl4.Text = sb.ToString();
                sb.Length    = 0;
                sb.Append(act.Args[4].Title);
                sb.Append(':');
                arglbl5.Text    = sb.ToString();
                sb.Length       = 0;
                arglbl1.Enabled = act.Args[0].Used;
                arglbl2.Enabled = act.Args[1].Used;
                arglbl3.Enabled = act.Args[2].Used;
                arglbl4.Enabled = act.Args[3].Used;
                arglbl5.Enabled = act.Args[4].Used;
                arg1.Enabled    = act.Args[0].Used;
                arg2.Enabled    = act.Args[1].Used;
                arg3.Enabled    = act.Args[2].Used;
                arg4.Enabled    = act.Args[3].Used;
                arg5.Enabled    = act.Args[4].Used;
                th = General.Types.GetArgumentHandler(act.Args[0]);
                th.SetValue(l.Args[0]); arg1.Text = th.GetStringValue();
                th = General.Types.GetArgumentHandler(act.Args[1]);
                th.SetValue(l.Args[1]); arg2.Text = th.GetStringValue();
                th = General.Types.GetArgumentHandler(act.Args[2]);
                th.SetValue(l.Args[2]); arg3.Text = th.GetStringValue();
                th = General.Types.GetArgumentHandler(act.Args[3]);
                th.SetValue(l.Args[3]); arg4.Text = th.GetStringValue();
                th = General.Types.GetArgumentHandler(act.Args[4]);
                th.SetValue(l.Args[4]); arg5.Text = th.GetStringValue();
            }

            // Front side available?
            if (l.Front != null)
            {
                // Show sidedef info
                sb.Append(" Front Sidedef ");
                sb.Append(l.Front.Index);
                sb.Append(' ');
                frontpanel.Text = sb.ToString();
                sb.Length       = 0;
                sb.Append(" Sector ");
                sb.Append(l.Front.Sector.Index);
                frontsector.Text    = sb.ToString();
                sb.Length           = 0;
                frontsector.Visible = true;
                sb.Append(l.Front.OffsetX);
                sb.Append(", ");
                sb.Append(l.Front.OffsetY);
                frontoffset.Text   = sb.ToString();
                sb.Length          = 0;
                fronthighname.Text = l.Front.HighTexture;
                frontmidname.Text  = l.Front.MiddleTexture;
                frontlowname.Text  = l.Front.LowTexture;
                DisplaySidedefTexture(fronthightex, l.Front.HighTexture, l.Front.HighRequired());
                DisplaySidedefTexture(frontmidtex, l.Front.MiddleTexture, l.Front.MiddleRequired());
                DisplaySidedefTexture(frontlowtex, l.Front.LowTexture, l.Front.LowRequired());
                frontoffsetlabel.Enabled = true;
                frontoffset.Enabled      = true;
                frontpanel.Enabled       = true;
            }
            else
            {
                // Show no info
                frontpanel.Text              = " Front Sidedef ";
                frontsector.Text             = "";
                frontsector.Visible          = false;
                frontoffsetlabel.Enabled     = false;
                frontoffset.Enabled          = false;
                frontpanel.Enabled           = false;
                frontoffset.Text             = "--, --";
                fronthighname.Text           = "";
                frontmidname.Text            = "";
                frontlowname.Text            = "";
                fronthightex.BackgroundImage = null;
                frontmidtex.BackgroundImage  = null;
                frontlowtex.BackgroundImage  = null;
            }

            // Back size available?
            if (l.Back != null)
            {
                // Show sidedef info
                sb.Append(" Back Sidedef ");
                sb.Append(l.Back.Index);
                sb.Append(' ');
                backpanel.Text = sb.ToString();
                sb.Length      = 0;

                sb.Append(" Sector ");
                sb.Append(l.Back.Sector.Index);
                backsector.Text    = sb.ToString();
                sb.Length          = 0;
                backsector.Visible = true;
                sb.Append(l.Back.OffsetX);
                sb.Append(", ");
                sb.Append(l.Back.OffsetY);
                backoffset.Text   = sb.ToString();
                sb.Length         = 0;
                backhighname.Text = l.Back.HighTexture;
                backmidname.Text  = l.Back.MiddleTexture;
                backlowname.Text  = l.Back.LowTexture;
                DisplaySidedefTexture(backhightex, l.Back.HighTexture, l.Back.HighRequired());
                DisplaySidedefTexture(backmidtex, l.Back.MiddleTexture, l.Back.MiddleRequired());
                DisplaySidedefTexture(backlowtex, l.Back.LowTexture, l.Back.LowRequired());
                backoffsetlabel.Enabled = true;
                backoffset.Enabled      = true;
                backpanel.Enabled       = true;
            }
            else
            {
                // Show no info
                backpanel.Text              = " Back Sidedef ";
                backsector.Text             = "";
                backsector.Visible          = false;
                backoffsetlabel.Enabled     = false;
                backoffset.Enabled          = false;
                backpanel.Enabled           = false;
                backoffset.Text             = "--, --";
                backhighname.Text           = "";
                backmidname.Text            = "";
                backlowname.Text            = "";
                backhightex.BackgroundImage = null;
                backmidtex.BackgroundImage  = null;
                backlowtex.BackgroundImage  = null;
            }

            // Position labels
            frontsector.Left = frontlowtex.Right - frontsector.Width;
            backsector.Left  = backlowtex.Right - backsector.Width;
            ResumeLayout();
            // Show the whole thing
            this.Show();
            this.Invalidate();
            //this.Update(); // ano - don't think this is needed, and is slow

            bNeedSetup = false;

            //Logger.WriteLogLine((General.stopwatch.Elapsed.TotalMilliseconds - starttime) + " milliseconds for linedefinfopanel.showinfo");
        }
예제 #20
0
        // This renders the associated things with the indication color
        public static void RenderReverseAssociations(IRenderer2D renderer, Association asso, List <Line3D> eventlines)
        {
            // Tag must be above zero
            if (General.GetByIndex(asso.Tags, 0) < 1)
            {
                return;
            }

            // Things
            foreach (Thing t in General.Map.Map.Things)
            {
                // Get the thing type info
                ThingTypeInfo ti = General.Map.Data.GetThingInfoEx(t.Type);

                // Known action on this thing?
                if ((t.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(t.Action))
                {
                    //Do not draw the association if this is a child link.
                    //  This prevents a reverse link to a thing via an argument, when it should be a direct tag-to-tag link instead.
                    if (ti != null && asso.DirectLinkType < 0 && asso.DirectLinkType != -t.Type)
                    {
                        continue;
                    }

                    LinedefActionInfo action = General.Map.Config.LinedefActions[t.Action];
                    if (((action.Args[0].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[0]))) ||
                        ((action.Args[1].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[1]))) ||
                        ((action.Args[2].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[2]))) ||
                        ((action.Args[3].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[3]))) ||
                        ((action.Args[4].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[4]))))
                    {
                        renderer.RenderThing(t, General.Colors.Indication, General.Settings.ActiveThingsAlpha);
                        if (General.Settings.GZShowEventLines)
                        {
                            eventlines.Add(new Line3D(t.Position, asso.Center));                                                           //mxd
                        }
                    }

                    //If there is a link setup on this thing, and it matches the association, then draw a direct link to any matching tag
                    if (ti != null && asso.DirectLinkType == t.Type && asso.Tags.Contains(t.Tag))
                    {
                        renderer.RenderThing(t, General.Colors.Indication, General.Settings.ActiveThingsAlpha);
                        if (General.Settings.GZShowEventLines)
                        {
                            eventlines.Add(new Line3D(t.Position, asso.Center));
                        }
                    }
                }
                //mxd. Thing action on this thing?
                else if (t.Action == 0)
                {
                    //Draw the association, unless it is a child link.
                    //  This prevents a reverse link to a thing via an argument, when it should be a direct tag-to-tag link instead.
                    if (ti != null && asso.DirectLinkType >= 0 && Math.Abs(asso.DirectLinkType) != t.Type)
                    {
                        if (((ti.Args[0].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[0]))) ||
                            ((ti.Args[1].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[1]))) ||
                            ((ti.Args[2].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[2]))) ||
                            ((ti.Args[3].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[3]))) ||
                            ((ti.Args[4].Type == (int)asso.Type) && (asso.Tags.Contains(t.Args[4]))))
                        {
                            renderer.RenderThing(t, General.Colors.Indication, General.Settings.ActiveThingsAlpha);
                            if (General.Settings.GZShowEventLines)
                            {
                                eventlines.Add(new Line3D(t.Position, asso.Center));
                            }
                        }
                    }
                }
            }
        }
예제 #21
0
        // This is called to perform a search (and replace)
        // Returns a list of items to show in the results list
        // replacewith is null when not replacing
        public override FindReplaceObject[] Find(string value, bool withinselection, bool replace, string replacewith, bool keepselection)
        {
            List <FindReplaceObject> objs = new List <FindReplaceObject>();

            // Where to search?
            ICollection <Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;

            // Find what? (mxd)
            Dictionary <string, bool> findflagslist = new Dictionary <string, bool>();

            foreach (string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                string f       = flag.Trim();
                bool   setflag = true;
                if (f.StartsWith("!"))
                {
                    setflag = false;
                    f       = f.Substring(1, f.Length - 1);
                }

                if (General.Map.Config.LinedefFlags.ContainsKey(f))
                {
                    findflagslist.Add(f, setflag);
                }
            }
            if (findflagslist.Count == 0)
            {
                MessageBox.Show("Invalid value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(objs.ToArray());
            }

            // Replace with what? (mxd)
            Dictionary <string, bool> replaceflagslist = new Dictionary <string, bool>();

            if (replace)
            {
                string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string flag in replaceflags)
                {
                    string f       = flag.Trim();
                    bool   setflag = true;
                    if (f.StartsWith("!"))
                    {
                        setflag = false;
                        f       = f.Substring(1, f.Length - 1);
                    }

                    if (!General.Map.Config.LinedefFlags.ContainsKey(f))
                    {
                        MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(objs.ToArray());
                    }
                    replaceflagslist.Add(f, setflag);
                }
            }

            // Go for all linedefs
            foreach (Linedef l in list)
            {
                bool match = true;

                // Parse the value string...
                foreach (KeyValuePair <string, bool> group in findflagslist)
                {
                    // ...and check if the flag doesn't match
                    if (group.Value != l.IsFlagSet(group.Key))
                    {
                        match = false;
                        break;
                    }
                }

                // Flags matches?
                if (match)
                {
                    // Replace flags (mxd)
                    if (replace)
                    {
                        // Set new flags
                        foreach (KeyValuePair <string, bool> group in replaceflagslist)
                        {
                            l.SetFlag(group.Key, group.Value);
                        }
                    }

                    // Add to list
                    LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
                    if (!info.IsNull)
                    {
                        objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
                    }
                    else
                    {
                        objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
                    }
                }
            }

            return(objs.ToArray());
        }
예제 #22
0
        // This shows the info
        public void ShowInfo(Thing t)
        {
            ThingTypeInfo     ti;
            LinedefActionInfo act = null;
            TypeHandler       th;
            string            actioninfo = "";
            string            zinfo;
            float             zvalue;

            // Show/hide stuff depending on format
            if (!General.Map.FormatInterface.HasActionArgs)
            {
                arglbl1.Visible = false;
                arglbl2.Visible = false;
                arglbl3.Visible = false;
                arglbl4.Visible = false;
                arglbl5.Visible = false;
                arg1.Visible    = false;
                arg2.Visible    = false;
                arg3.Visible    = false;
                arg4.Visible    = false;
                arg5.Visible    = false;
                infopanel.Width = doomformatwidth;
            }
            else
            {
                arglbl1.Visible = true;
                arglbl2.Visible = true;
                arglbl3.Visible = true;
                arglbl4.Visible = true;
                arglbl5.Visible = true;
                arg1.Visible    = true;
                arg2.Visible    = true;
                arg3.Visible    = true;
                arg4.Visible    = true;
                arg5.Visible    = true;
                infopanel.Width = hexenformatwidth;
            }

            // Move panel
            spritepanel.Left = infopanel.Left + infopanel.Width + infopanel.Margin.Right + spritepanel.Margin.Left;

            // Lookup thing info
            ti = General.Map.Data.GetThingInfo(t.Type);

            // Get thing action information
            if (General.Map.Config.LinedefActions.ContainsKey(t.Action))
            {
                act        = General.Map.Config.LinedefActions[t.Action];
                actioninfo = act.ToString();
            }
            else if (t.Action == 0)
            {
                actioninfo = t.Action.ToString() + " - None";
            }
            else
            {
                actioninfo = t.Action.ToString() + " - Unknown";
            }

            // Determine z info to show
            t.DetermineSector();
            if (ti.AbsoluteZ)
            {
                zvalue = t.Position.z;
                zinfo  = zvalue.ToString();
            }
            else
            {
                if (t.Sector != null)
                {
                    // Hangs from ceiling?
                    if (ti.Hangs)
                    {
                        zvalue = (float)t.Sector.CeilHeight + t.Position.z;
                        zinfo  = zvalue.ToString();
                    }
                    else
                    {
                        zvalue = (float)t.Sector.FloorHeight + t.Position.z;
                        zinfo  = zvalue.ToString();
                    }
                }
                else
                {
                    zvalue = t.Position.z;
                    if (zvalue >= 0.0f)
                    {
                        zinfo = "+" + zvalue.ToString();
                    }
                    else
                    {
                        zinfo = zvalue.ToString();
                    }
                }
            }

            // Thing info
            infopanel.Text = " Thing " + t.Index + " ";
            type.Text      = t.Type + " - " + ti.Title;
            action.Text    = actioninfo;
            position.Text  = t.Position.x.ToString() + ", " + t.Position.y.ToString() + ", " + zinfo;
            tag.Text       = t.Tag.ToString();
            angle.Text     = t.AngleDoom.ToString() + "\u00B0";

            // Sprite
            if (ti.Sprite.ToLowerInvariant().StartsWith(DataManager.INTERNAL_PREFIX) && (ti.Sprite.Length > DataManager.INTERNAL_PREFIX.Length))
            {
                spritename.Text = "";
                General.DisplayZoomedImage(spritetex, General.Map.Data.GetSpriteImage(ti.Sprite).GetBitmap());
            }
            else if (ti.Sprite.Length > 0)
            {
                spritename.Text = ti.Sprite;
                General.DisplayZoomedImage(spritetex, General.Map.Data.GetSpriteImage(ti.Sprite).GetPreview());
            }
            else
            {
                spritename.Text           = "";
                spritetex.BackgroundImage = null;
            }

            // Arguments
            if (act != null)
            {
                arglbl1.Text    = act.Args[0].Title + ":";
                arglbl2.Text    = act.Args[1].Title + ":";
                arglbl3.Text    = act.Args[2].Title + ":";
                arglbl4.Text    = act.Args[3].Title + ":";
                arglbl5.Text    = act.Args[4].Title + ":";
                arglbl1.Enabled = act.Args[0].Used;
                arglbl2.Enabled = act.Args[1].Used;
                arglbl3.Enabled = act.Args[2].Used;
                arglbl4.Enabled = act.Args[3].Used;
                arglbl5.Enabled = act.Args[4].Used;
                arg1.Enabled    = act.Args[0].Used;
                arg2.Enabled    = act.Args[1].Used;
                arg3.Enabled    = act.Args[2].Used;
                arg4.Enabled    = act.Args[3].Used;
                arg5.Enabled    = act.Args[4].Used;
                th = General.Types.GetArgumentHandler(act.Args[0]);
                th.SetValue(t.Args[0]); arg1.Text = th.GetStringValue();
                th = General.Types.GetArgumentHandler(act.Args[1]);
                th.SetValue(t.Args[1]); arg2.Text = th.GetStringValue();
                th = General.Types.GetArgumentHandler(act.Args[2]);
                th.SetValue(t.Args[2]); arg3.Text = th.GetStringValue();
                th = General.Types.GetArgumentHandler(act.Args[3]);
                th.SetValue(t.Args[3]); arg4.Text = th.GetStringValue();
                th = General.Types.GetArgumentHandler(act.Args[4]);
                th.SetValue(t.Args[4]); arg5.Text = th.GetStringValue();
            }
            else
            {
                arglbl1.Text    = "Argument 1:";
                arglbl2.Text    = "Argument 2:";
                arglbl3.Text    = "Argument 3:";
                arglbl4.Text    = "Argument 4:";
                arglbl5.Text    = "Argument 5:";
                arglbl1.Enabled = false;
                arglbl2.Enabled = false;
                arglbl3.Enabled = false;
                arglbl4.Enabled = false;
                arglbl5.Enabled = false;
                arg1.Enabled    = false;
                arg2.Enabled    = false;
                arg3.Enabled    = false;
                arg4.Enabled    = false;
                arg5.Enabled    = false;
                arg1.Text       = "-";
                arg2.Text       = "-";
                arg3.Text       = "-";
                arg4.Text       = "-";
                arg5.Text       = "-";
            }

            // Show the whole thing
            this.Show();
            //this.Update(); // ano - don't think this is needed, and is slow
        }
예제 #23
0
        // This highlights a new item
        protected void Highlight(Thing t)
        {
            bool completeredraw      = false;
            LinedefActionInfo action = null;

            // Often we can get away by simply undrawing the previous
            // highlight and drawing the new highlight. But if associations
            // are or were drawn we need to redraw the entire display.

            // Previous association highlights something?
            if ((highlighted != null) && (highlighted.Tag > 0))
            {
                completeredraw = true;
            }

            // Set highlight association
            if (t != null)
            {
                highlightasso.Set(t.Tag, UniversalType.ThingTag);
            }
            else
            {
                highlightasso.Set(0, 0);
            }

            // New association highlights something?
            if ((t != null) && (t.Tag > 0))
            {
                completeredraw = true;
            }

            if (t != null)
            {
                // Check if we can find the linedefs action
                if ((t.Action > 0) && General.Map.Config.LinedefActions.ContainsKey(t.Action))
                {
                    action = General.Map.Config.LinedefActions[t.Action];
                }
            }

            // Determine linedef associations
            for (int i = 0; i < Thing.NUM_ARGS; i++)
            {
                // Previous association highlights something?
                if ((association[i].type == UniversalType.SectorTag) ||
                    (association[i].type == UniversalType.LinedefTag) ||
                    (association[i].type == UniversalType.ThingTag))
                {
                    completeredraw = true;
                }

                // Make new association
                if (action != null)
                {
                    association[i].Set(t.Args[i], action.Args[i].Type);
                }
                else
                {
                    association[i].Set(0, 0);
                }

                // New association highlights something?
                if ((association[i].type == UniversalType.SectorTag) ||
                    (association[i].type == UniversalType.LinedefTag) ||
                    (association[i].type == UniversalType.ThingTag))
                {
                    completeredraw = true;
                }
            }

            // If we're changing associations, then we
            // need to redraw the entire display
            if (completeredraw)
            {
                // Set new highlight and redraw completely
                highlighted = t;
                General.Interface.RedrawDisplay();
            }
            else
            {
                // Update display
                if (renderer.StartThings(false))
                {
                    // Undraw previous highlight
                    if ((highlighted != null) && !highlighted.IsDisposed)
                    {
                        renderer.RenderThing(highlighted, renderer.DetermineThingColor(highlighted), 1.0f);
                    }

                    // Set new highlight
                    highlighted = t;

                    // Render highlighted item
                    if ((highlighted != null) && !highlighted.IsDisposed)
                    {
                        renderer.RenderThing(highlighted, General.Colors.Highlight, 1.0f);
                    }

                    // Done
                    renderer.Finish();
                    renderer.Present();
                }
            }

            // Show highlight info
            if ((highlighted != null) && !highlighted.IsDisposed)
            {
                General.Interface.ShowThingInfo(highlighted);
            }
            else
            {
                General.Interface.HideInfo();
            }
        }
예제 #24
0
        // This is called to perform a search (and replace)
        // Returns a list of items to show in the results list
        // replacewith is null when not replacing
        public override FindReplaceObject[] Find(string value, bool withinselection, bool replace, string replacewith, bool keepselection)
        {
            List <FindReplaceObject> objs = new List <FindReplaceObject>();

            // Interpret the replacement
            int    replaceaction  = 0;
            string replacearg0str = string.Empty; //mxd

            int[] replaceargs = null;             //mxd
            if (replace)
            {
                string[] replaceparts = replacewith.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                // If it cannot be interpreted, set replacewith to null (not replacing at all)
                if (replaceparts.Length == 0)
                {
                    replacewith = null;                                          //mxd
                }
                if (!int.TryParse(replaceparts[0], 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());
                }

                //mxd. Now try parsing the args
                if (replaceparts.Length > 1)
                {
                    replaceargs = new[] { int.MinValue, int.MinValue, int.MinValue, int.MinValue, int.MinValue };
                    int i = 1;

                    //mxd. Named script search support...
                    if (General.Map.UDMF)
                    {
                        string possiblescriptname = replaceparts[1].Trim();
                        int    tmp;
                        if (!string.IsNullOrEmpty(possiblescriptname) && possiblescriptname != "*" && !int.TryParse(possiblescriptname, out tmp))
                        {
                            replacearg0str = possiblescriptname.Replace("\"", "");
                            i = 2;
                        }
                    }

                    for (; i < replaceparts.Length && i < replaceargs.Length + 1; i++)
                    {
                        int argout;
                        if (replaceparts[i].Trim() == "*")
                        {
                            continue;                                                       //mxd. Any arg value support
                        }
                        if (int.TryParse(replaceparts[i].Trim(), out argout))
                        {
                            replaceargs[i - 1] = argout;
                        }
                    }
                }
            }

            // Interpret the number given
            int action;

            string[] parts = value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            //For the search, the user may make the following queries:
            //	action arg0 arg1 arg2 arg3 arg4
            //	action arg0str arg1 arg2 arg3 arg4
            //
            //this allows users to search for lines that contain actions with specific arguments.
            //useful for locating script lines

            if (int.TryParse(parts[0], out action))
            {
                int[]  args    = null;
                string arg0str = string.Empty;                 //mxd

                bool isacs = Array.IndexOf(GZGeneral.ACS_SPECIALS, action) != -1;

                //parse the arg values out
                if (parts.Length > 1)
                {
                    args = new[] { int.MinValue, int.MinValue, int.MinValue, int.MinValue, int.MinValue };
                    int i = 1;

                    //mxd. Named script search support...
                    if (General.Map.UDMF)
                    {
                        // [ZZ] edit: we can enclose number with "" to signify a named script called "1".
                        //      this is achieved by trying to parse the number before removing "'s.
                        string possiblescriptname = parts[1].Trim();
                        int    tmp;
                        if (!string.IsNullOrEmpty(possiblescriptname) && possiblescriptname != "*" && !int.TryParse(possiblescriptname, out tmp))
                        {
                            arg0str = possiblescriptname.Replace("\"", "").ToLowerInvariant();
                            i       = 2;
                        }
                    }

                    for (; i < parts.Length && i < args.Length + 1; i++)
                    {
                        int argout;
                        if (parts[i].Trim() == "*")
                        {
                            continue;                                                //mxd. Any arg value support
                        }
                        if (int.TryParse(parts[i].Trim(), out argout))
                        {
                            args[i - 1] = argout;
                        }
                    }
                }

                //mxd
                HashSet <int> expectedbits = GetGeneralizedBits(action);

                // Where to search?
                ICollection <Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;

                // Go for all linedefs
                foreach (Linedef l in list)
                {
                    // Action matches? -1 means any action (mxd)
                    if ((action == -1 && l.Action == 0) || (action > -1 && (l.Action != action && !BitsMatch(l.Action, expectedbits))))
                    {
                        continue;
                    }

                    bool   match   = true;
                    string argtext = "";

                    //if args were specified, then process them
                    if (args != null)
                    {
                        int x = 0;
                        argtext = ". Args: ";

                        //mxd. Check script name...
                        if (!string.IsNullOrEmpty(arg0str))
                        {
                            string s = l.Fields.GetValue("arg0str", string.Empty);
                            if (s.ToLowerInvariant() != arg0str)
                            {
                                match = false;
                            }
                            else
                            {
                                argtext += "\"" + s + "\"";
                            }

                            x = 1;
                        }

                        for (; x < args.Length; x++)
                        {
                            if (args[x] != int.MinValue && args[x] != l.Args[x])
                            {
                                match = false;
                                break;
                            }
                            argtext += (x == 0 ? "" : ", ") + l.Args[x];
                        }
                    }
                    //mxd. Add action args
                    else
                    {
                        List <string> argslist = new List <string>();

                        // Process args, drop trailing zeroes
                        for (int i = l.Args.Length - 1; i > -1; i--)
                        {
                            if (l.Args[i] == 0 && argslist.Count == 0)
                            {
                                continue;                                                                   // Skip tail zeroes
                            }
                            argslist.Insert(0, l.Args[i].ToString());
                        }

                        // Process arg0str...
                        //if(Array.IndexOf(GZGeneral.ACS_SPECIALS, l.Action) != -1)
                        {
                            string s = l.Fields.GetValue("arg0str", string.Empty);
                            if (!string.IsNullOrEmpty(s))
                            {
                                if (argslist.Count > 0)
                                {
                                    argslist[0] = "\"" + s + "\"";
                                }
                                else
                                {
                                    argslist.Add("\"" + s + "\"");
                                }
                            }
                        }

                        // Create args string
                        if (argslist.Count > 0)
                        {
                            argtext = ". Args: " + string.Join(", ", argslist.ToArray());
                        }
                    }

                    if (match)
                    {
                        // Replace
                        LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);

                        if (replace)
                        {
                            l.Action = replaceaction;
                            info     = General.Map.Config.GetLinedefActionInfo(l.Action);

                            //mxd. Replace args as well?
                            if (replaceargs != null)
                            {
                                int i = 0;
                                if (!string.IsNullOrEmpty(replacearg0str) && info.Args[0].Str)                                // [ZZ] make sure that arg0str is supported for this special.
                                {
                                    l.Fields["arg0str"] = new UniValue(UniversalType.String, replacearg0str);
                                    i = 1;
                                }

                                for (; i < replaceargs.Length; i++)
                                {
                                    if (replaceargs[i] != int.MinValue)
                                    {
                                        l.Args[i] = replaceargs[i];
                                    }
                                }
                            }
                        }

                        // Add to list
                        if (!info.IsNull)
                        {
                            objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + argtext + ")"));
                        }
                        else
                        {
                            objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (Action " + l.Action + argtext + ")"));
                        }
                    }
                }
            }

            return(objs.ToArray());
        }
예제 #25
0
        // This is called to perform a search (and replace)
        // Returns a list of items to show in the results list
        // replacewith is null when not replacing
        public override FindReplaceObject[] Find(string value, bool withinselection, bool replace, string replacewith, bool keepselection)
        {
            List <FindReplaceObject> objs = new List <FindReplaceObject>();

            // Interpret the replacement
            int replacetag = 0;

            if (replace)
            {
                // If it cannot be interpreted, set replacewith to null (not replacing at all)
                if (!int.TryParse(replacewith, out replacetag))
                {
                    replacewith = null;
                }
                if (replacetag < General.Map.FormatInterface.MinTag)
                {
                    replacewith = null;
                }
                if (replacetag > General.Map.FormatInterface.MaxTag)
                {
                    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
            int tag;

            if (int.TryParse(value, out tag))
            {
                // Where to search?
                ICollection <Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;

                // Go for all linedefs
                foreach (Linedef l in list)
                {
                    // Tag matches?
                    int index = l.Tags.IndexOf(tag);
                    if (index != -1)
                    {
                        // Replace
                        if (replace)
                        {
                            //mxd. Make a copy of tags, otherwise BeforePropsChange will be triggered after tag changes
                            List <int> tags = new List <int>(l.Tags);
                            tags[index] = replacetag;
                            l.Tags      = tags.Distinct().ToList();                        // We don't want duplicates
                        }

                        // Add to list
                        LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
                        if (!info.IsNull)
                        {
                            objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
                        }
                        else
                        {
                            objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
                        }
                    }
                }
            }

            return(objs.ToArray());
        }