예제 #1
0
        }                                                                                                          //mxd

        internal void ModifyByDecorateActor(ActorStructure actor, bool replacetitle)
        {
            // Keep reference to actor
            this.actor     = actor;
            this.classname = actor.ClassName;             //mxd

            // Set the title
            if (actor.HasPropertyWithValue("$title"))
            {
                title = actor.GetPropertyAllValues("$title");
            }
            else if (actor.HasPropertyWithValue("tag"))
            {
                string tag = actor.GetPropertyAllValues("tag");
                if (!tag.StartsWith("\"$"))
                {
                    title = tag;                                        //mxd. Don't use LANGUAGE keywords.
                }
            }

            if (string.IsNullOrEmpty(title) || replacetitle)
            {
                title = actor.ClassName;
            }

            //mxd. Color override?
            if (actor.HasPropertyWithValue("$color"))
            {
                int ci = actor.GetPropertyValueInt("$color", 0);
                color = (ci == 0 || ci > 19 ? 18 : ci);
            }

            //mxd. Custom argument titles?
            for (int i = 0; i < args.Length; i++)
            {
                if (!actor.HasPropertyWithValue("$arg" + i))
                {
                    continue;
                }
                string argtitle       = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i));
                string argtooltip     = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "tooltip").Replace("\\n", Environment.NewLine));
                int    argtype        = actor.GetPropertyValueInt("$arg" + i + "type", 0);
                int    defaultvalue   = actor.GetPropertyValueInt("$arg" + i + "default", 0);
                string argenum        = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "enum"));
                string argrenderstyle = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "renderstyle"));
                string argrendercolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "rendercolor"));
                args[i] = new ArgumentInfo(title, argtitle, argtooltip, argrenderstyle, argrendercolor, argtype, defaultvalue, argenum, General.Map.Config.Enums);
            }

            //mxd. Some SLADE compatibility
            if (actor.HasProperty("$angled"))
            {
                this.arrow = true;
            }
            else if (actor.HasProperty("$notangled"))
            {
                this.arrow = false;
            }

            //mxd. Marked as obsolete?
            if (actor.HasPropertyWithValue("$obsolete"))
            {
                obsoletemessage = actor.GetPropertyValueString("$obsolete", 0, true);
                obsolete        = true;
                color           = 4;       //red
            }

            // Remove doublequotes from title
            title = ZDTextParser.StripQuotes(title);             //mxd

            // Set sprite
            StateStructure.FrameInfo info = actor.FindSuitableSprite(); //mxd
            if (!locksprite && info != null)                            //mxd. Added locksprite property
            {
                sprite = info.Sprite;
            }
            else if (string.IsNullOrEmpty(sprite))           //mxd
            {
                sprite = DataManager.INTERNAL_PREFIX + "unknownthing";
            }

            //mxd. Store dynamic light name
            lightname = (info != null ? info.LightName : string.Empty);

            //mxd. Create sprite frame
            this.spriteframe = new[] { new SpriteFrameInfo {
                                           Sprite = sprite, SpriteLongName = Lump.MakeLongName(sprite, true)
                                       } };

            // Set sprite scale (mxd. Scale is translated to xscale and yscale in ActorStructure)
            if (actor.HasPropertyWithValue("xscale"))
            {
                this.spritescale.Width = actor.GetPropertyValueFloat("xscale", 0);
            }

            if (actor.HasPropertyWithValue("yscale"))
            {
                this.spritescale.Height = actor.GetPropertyValueFloat("yscale", 0);
            }

            // Size
            if (actor.HasPropertyWithValue("radius"))
            {
                radius = actor.GetPropertyValueInt("radius", 0);
            }
            if (actor.HasPropertyWithValue("height"))
            {
                height = actor.GetPropertyValueInt("height", 0);
            }

            //mxd. DistanceCheck. The value is CVAR. Also we'll need squared value
            if (actor.HasPropertyWithValue("distancecheck"))
            {
                string cvarname = actor.GetPropertyValueString("distancecheck", 0);
                if (!General.Map.Data.CVars.Integers.ContainsKey(cvarname))
                {
                    General.ErrorLogger.Add(ErrorType.Error, "Error in actor \"" + title + "\":" + index + ". DistanceCheck property references undefined cvar \"" + cvarname + "\"");
                    distancechecksq = int.MaxValue;
                }
                else
                {
                    distancechecksq = (int)Math.Pow(General.Map.Data.CVars.Integers[cvarname], 2);
                }
            }

            //mxd. Renderstyle
            if (actor.HasPropertyWithValue("renderstyle") && !actor.HasProperty("$ignorerenderstyle"))
            {
                renderstyle = actor.GetPropertyValueString("renderstyle", 0, true).ToLower();
            }

            //mxd. Alpha
            if (actor.HasPropertyWithValue("alpha"))
            {
                this.alpha     = General.Clamp(actor.GetPropertyValueFloat("alpha", 0), 0f, 1f);
                this.alphabyte = (byte)(this.alpha * 255);
            }
            else if (actor.HasProperty("defaultalpha"))
            {
                this.alpha     = (General.Map.Config.BaseGame == GameType.HERETIC ? 0.4f : 0.6f);
                this.alphabyte = (byte)(this.alpha * 255);
            }

            //mxd. BRIGHT
            this.bright = (info != null && info.Bright) || actor.GetFlagValue("bright", false);

            // Safety
            if (this.radius < 4f || this.fixedsize)
            {
                this.radius = THING_FIXED_SIZE;
            }
            if (this.spritescale.Width == 0.0f)
            {
                this.spritescale.Width = 1.0f;
            }
            if (this.spritescale.Height == 0.0f)
            {
                this.spritescale.Height = 1.0f;
            }

            // Options
            hangs = actor.GetFlagValue("spawnceiling", hangs);
            int blockvalue = (blocking > 0) ? blocking : 2;

            blocking    = actor.GetFlagValue("solid", (blocking != 0)) ? blockvalue : 0;
            xybillboard = actor.GetFlagValue("forcexybillboard", false);             //mxd

            //mxd. GZDoom rendering flags
            rollsprite = actor.GetFlagValue("rollsprite", false);
            if (rollsprite)
            {
                rollcenter = actor.GetFlagValue("rollcenter", false);
            }
            if (actor.GetFlagValue("wallsprite", false))
            {
                rendermode = ThingRenderMode.WALLSPRITE;
            }
            if (actor.GetFlagValue("flatsprite", false))
            {
                // WALLSPRITE + FLATSPRITE = HORRIBLE GLITCHES in GZDoom
                if (rendermode == ThingRenderMode.WALLSPRITE)
                {
                    General.ErrorLogger.Add(ErrorType.Error, "Error in actor \"" + title + "\":" + index + ". WALLSPRITE and FLATSPRITE flags can not be combined");
                }
                else
                {
                    rendermode = ThingRenderMode.FLATSPRITE;
                    dontflip   = actor.GetFlagValue("dontflip", false);
                }
            }

            //mxd
            if (blocking > THING_BLOCKING_NONE)
            {
                errorcheck = THING_ERROR_INSIDE_STUCK;
            }
        }
예제 #2
0
        //mxd. Constructor for an argument info defined in DECORATE
        // [ZZ] Constructor for an argument info defined in DECORATE/ZScript. reworked.
        internal ArgumentInfo(ActorStructure actor, int i)
        {
            if (!actor.HasPropertyWithValue("$arg" + i))
            {
                used = false;
                return;
            }

            string argtitle = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i));
            string tooltip = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "tooltip").Replace("\\n", Environment.NewLine));
            int    type = actor.GetPropertyValueInt("$arg" + i + "type", 0);
            string targetclasses = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "targetclasses"));
            int    defaultvalue = actor.GetPropertyValueInt("$arg" + i + "default", 0);
            string enumstr = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "enum"));
            string renderstyle = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "renderstyle"));
            string rendercolor, minrange, maxrange, minrangecolor, maxrangecolor;
            bool   str         = (actor.HasProperty("$arg" + i + "str"));
            string argtitlestr = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "str"));

            if (string.IsNullOrEmpty(argtitlestr))
            {
                argtitlestr = argtitle;
            }
            if (!string.IsNullOrEmpty(renderstyle))
            {
                rendercolor   = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "rendercolor"));
                minrange      = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "minrange"));
                minrangecolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "minrangecolor"));
                maxrange      = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "maxrange"));
                maxrangecolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "maxrangecolor"));
            }
            else
            {
                rendercolor = string.Empty; minrange = string.Empty; maxrange = string.Empty; minrangecolor = string.Empty; maxrangecolor = string.Empty;
            }

            string actorname = actor.ClassName;
            IDictionary <string, EnumList> enums = General.Map.Config.Enums;

            this.used         = true;
            this.title        = argtitle;
            this.tooltip      = tooltip;
            this.defaultvalue = defaultvalue;
            this.flagslist    = new EnumList();          //mxd
            this.str          = str;
            this.titlestr     = argtitlestr;

            // Get rendering hint settings
            switch (renderstyle.ToLowerInvariant())
            {
            case "circle": this.renderstyle = ArgumentRenderStyle.CIRCLE; break;

            case "rectangle": this.renderstyle = ArgumentRenderStyle.RECTANGLE; break;

            default:
                this.renderstyle = ArgumentRenderStyle.NONE;
                if (!string.IsNullOrEmpty(renderstyle))
                {
                    General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + argtitle + "\" has unknown renderstyle \"" + renderstyle + "\"!");
                }
                break;
            }

            if (this.renderstyle != ArgumentRenderStyle.NONE)
            {
                // Get rendercolor
                this.rendercolor = General.Colors.InfoLine;

                if (!string.IsNullOrEmpty(rendercolor) && !ZDTextParser.GetColorFromString(rendercolor, out this.rendercolor))
                {
                    General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + argtitle + "\": unable to get rendercolor from value \"" + rendercolor + "\"!");
                }

                this.rendercolor.a = HELPER_SHAPE_ALPHA;

                // Get minrange settings
                if (int.TryParse(minrange, NumberStyles.Integer, CultureInfo.InvariantCulture, out this.minrange) && this.minrange > 0f)
                {
                    // Get minrangecolor
                    this.minrangecolor = General.Colors.Indication;

                    if (!string.IsNullOrEmpty(minrangecolor) && !ZDTextParser.GetColorFromString(minrangecolor, out this.minrangecolor))
                    {
                        General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + this.title + "\": unable to get minrangecolor from value \"" + minrangecolor + "\"!");
                    }

                    this.minrangecolor.a = RANGE_SHAPE_ALPHA;
                }

                // Get maxrange settings
                if (int.TryParse(maxrange, NumberStyles.Integer, CultureInfo.InvariantCulture, out this.maxrange) && this.maxrange > 0f)
                {
                    // Get minrangecolor
                    this.maxrangecolor = General.Colors.Indication;

                    if (!string.IsNullOrEmpty(maxrangecolor) && !ZDTextParser.GetColorFromString(maxrangecolor, out this.maxrangecolor))
                    {
                        General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + this.title + "\": unable to get maxrangecolor from value \"" + maxrangecolor + "\"!");
                    }

                    this.maxrangecolor.a = RANGE_SHAPE_ALPHA;
                }

                // Update tooltip?
                if (this.minrange > 0f || this.maxrange > 0f)
                {
                    if (!string.IsNullOrEmpty(this.tooltip))
                    {
                        this.tooltip += Environment.NewLine + Environment.NewLine;
                    }

                    if (this.minrange > 0f && this.maxrange > 0f)
                    {
                        this.tooltip += "Expected range: " + this.minrange + " - " + this.maxrange;
                    }
                    else if (this.minrange > 0f)
                    {
                        this.tooltip += "Minimum: " + this.minrange;
                    }
                    else
                    {
                        this.tooltip += "Maximum: " + this.maxrange;
                    }
                }
            }

            //Check for TargetClass
            this.targetclasses = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);
            if (type == (int)UniversalType.ThingTag)
            {
                if (!string.IsNullOrEmpty(targetclasses))
                {
                    foreach (string tclass in targetclasses.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        this.targetclasses.Add(tclass.Trim());
                    }
                }
            }

            // Get argument type
            if (System.Enum.IsDefined(typeof(UniversalType), type))
            {
                this.type = type;
            }
            else
            {
                General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + argtitle + "\" has unknown type " + type + "!");
                this.type = 0;
            }

            // Get or create enum
            if (!string.IsNullOrEmpty(enumstr))
            {
                if (enums.ContainsKey(enumstr.ToLowerInvariant()))
                {
                    this.enumlist = enums[enumstr.ToLowerInvariant()];
                }
                else
                {
                    Configuration cfg = new Configuration();
                    if (cfg.InputConfiguration("enum" + enumstr, true))
                    {
                        IDictionary argdic = cfg.ReadSetting("enum", new Hashtable());
                        if (argdic.Keys.Count > 0)
                        {
                            this.enumlist = new EnumList(argdic);
                        }
                        else
                        {
                            General.ErrorLogger.Add(ErrorType.Error, actorname + ": unable to parse explicit enum structure for argument \"" + argtitle + "\"!");
                        }
                    }
                    else
                    {
                        General.ErrorLogger.Add(ErrorType.Error, actorname + ": unable to parse enum structure for argument \"" + argtitle + "\"!");
                    }
                }
            }

            if (this.enumlist == null)
            {
                this.enumlist = new EnumList();
            }
        }