// Constructor internal ThingTypeInfo(int index) { // Initialize this.index = index; this.category = null; this.actor = null; this.title = "<" + index.ToString(CultureInfo.InvariantCulture) + ">"; this.sprite = DataManager.INTERNAL_PREFIX + "unknownthing"; this.color = 0; this.arrow = true; this.radius = 10f; this.height = 20f; this.hangs = false; this.blocking = 0; this.errorcheck = 0; this.spritescale = new SizeF(1.0f, 1.0f); this.fixedsize = false; this.spritelongname = long.MaxValue; this.args = new ArgumentInfo[Linedef.NUM_ARGS]; this.isknown = false; this.absolutez = false; // We have no destructor GC.SuppressFinalize(this); }
//mxd. Constructor internal ThingTypeInfo(ThingCategory cat, ActorStructure actor, int index) { // Initialize this.index = index; this.category = cat; this.title = ""; this.actor = actor; this.classname = actor.ClassName; //mxd this.isknown = true; this.bright = false; //mxd this.distancechecksq = int.MaxValue; //mxd this.args = new ArgumentInfo[Linedef.NUM_ARGS]; for (int i = 0; i < Linedef.NUM_ARGS; i++) { this.args[i] = new ArgumentInfo(i); } // Read properties this.sprite = cat.Sprite; this.spriteframe = new[] { new SpriteFrameInfo { Sprite = sprite, SpriteLongName = Lump.MakeLongName(sprite, true), } }; //mxd this.color = cat.Color; this.alpha = cat.Alpha; //mxd this.alphabyte = (byte)(this.alpha * 255); //mxd this.renderstyle = cat.RenderStyle; //mxd this.arrow = (cat.Arrow != 0); this.radius = cat.Radius; this.height = cat.Height; this.hangs = (cat.Hangs != 0); this.blocking = cat.Blocking; this.errorcheck = cat.ErrorCheck; this.fixedsize = cat.FixedSize; this.fixedrotation = cat.FixedRotation; //mxd this.absolutez = cat.AbsoluteZ; this.spritescale = new SizeF(cat.SpriteScale, cat.SpriteScale); this.flagsrename = new Dictionary <string, Dictionary <string, string> >(StringComparer.OrdinalIgnoreCase); //mxd // Safety if (this.hangs && this.absolutez) { this.hangs = false; //mxd } // Apply settings from actor ModifyByDecorateActor(actor); //mxd. Create sprite frame this.spriteframe = new[] { new SpriteFrameInfo { Sprite = sprite, SpriteLongName = Lump.MakeLongName(sprite, true) } }; // this.optional = false; // [ZZ] // We have no destructor GC.SuppressFinalize(this); }
// Constructor internal ThingTypeInfo(int index, ThingTypeInfo other) { // Initialize this.index = index; this.category = other.category; this.title = other.title; this.actor = other.actor; this.classname = other.classname; //mxd this.isknown = true; this.args = new ArgumentInfo[Linedef.NUM_ARGS]; for (int i = 0; i < Linedef.NUM_ARGS; i++) { this.args[i] = other.args[i]; } // Copy properties this.sprite = other.sprite; this.spriteframe = new SpriteFrameInfo[other.spriteframe.Length]; //mxd other.spriteframe.CopyTo(this.spriteframe, 0); //mxd this.color = other.color; this.alpha = other.alpha; //mxd this.alphabyte = other.alphabyte; //mxd this.renderstyle = other.renderstyle; //mxd this.bright = other.bright; //mxd this.arrow = other.arrow; this.radius = other.radius; this.height = other.height; this.distancechecksq = other.distancechecksq; //mxd this.hangs = other.hangs; this.blocking = other.blocking; this.errorcheck = other.errorcheck; this.fixedsize = other.fixedsize; this.fixedrotation = other.fixedrotation; //mxd this.absolutez = other.absolutez; this.xybillboard = other.xybillboard; //mxd this.spritescale = new SizeF(other.spritescale.Width, other.spritescale.Height); this.flagsrename = new Dictionary <string, Dictionary <string, string> >(StringComparer.OrdinalIgnoreCase); //mxd //mxd. Copy GZDoom rendering properties this.rendermode = other.rendermode; this.rollsprite = other.rollsprite; this.rollcenter = other.rollcenter; // this.dynamiclighttype = other.dynamiclighttype; // this.optional = other.optional; // We have no destructor GC.SuppressFinalize(this); }
// Constructor internal ThingTypeInfo(ThingCategory cat, int index, Configuration cfg, IDictionary <string, EnumList> enums) { string key = index.ToString(CultureInfo.InvariantCulture); // Initialize this.index = index; this.category = cat; this.args = new ArgumentInfo[Linedef.NUM_ARGS]; this.isknown = true; this.actor = null; // Read properties this.title = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".title", "<" + key + ">"); this.sprite = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".sprite", cat.Sprite); this.color = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".color", cat.Color); this.arrow = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".arrow", cat.Arrow) != 0); this.radius = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".width", cat.Radius); this.height = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".height", cat.Height); this.hangs = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".hangs", cat.Hangs) != 0); this.blocking = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".blocking", cat.Blocking); this.errorcheck = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".error", cat.ErrorCheck); this.fixedsize = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".fixedsize", cat.FixedSize); this.absolutez = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".absolutez", cat.AbsoluteZ); float sscale = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".spritescale", cat.SpriteScale); this.spritescale = new SizeF(sscale, sscale); // Read the args for (int i = 0; i < Linedef.NUM_ARGS; i++) { this.args[i] = new ArgumentInfo(cfg, "thingtypes." + cat.Name + "." + key, i, enums); } // Safety if (this.radius < 4f) { this.radius = 8f; } // Make long name for sprite lookup if (this.sprite.Length <= 8) { this.spritelongname = Lump.MakeLongName(this.sprite); } else { this.spritelongname = long.MaxValue; } // We have no destructor GC.SuppressFinalize(this); }
// [ZZ] this is for proper inheritance of lights. // technically this can be found by parsing gzdoom.pk3/mapinfo/common.txt, but I wouldn't do that without a good reason for now. public static LightData GetGZLightTypeByClass(ActorStructure actor) { ActorStructure p = actor; while (p != null) { // found dynamic light type. alter it by actor flags. // +MISSILEMORE makes it additive. // +MISSILEEVENMORE makes it subtractive. // +INCOMBAT makes it attenuated. LightData ld = GetLightDataByClass(p.ClassName); if (ld != null) { if (ld.LightDef != LightDef.VAVOOM_GENERIC && ld.LightDef != LightDef.VAVOOM_COLORED) // not vavoom { int baseType = ld.LightNum % 10; int dispType = ld.LightNum - baseType; if (actor.GetFlagValue("MISSILEMORE", false) || actor.GetFlagValue("DYNAMICLIGHT.ADDITIVE", false)) { dispType = 9810; } else if (actor.GetFlagValue("MISSILEEVENMORE", false) || actor.GetFlagValue("DYNAMICLIGHT.SUBTRACTIVE", false)) { dispType = 9820; } else if (actor.GetFlagValue("INCOMBAT", false) || actor.GetFlagValue("DYNAMICLIGHT.ATTENUATE", false)) { dispType = 9830; } if (!actor.GetFlagValue("DYNAMICLIGHT.SPOT", false) && dispType >= 9840) { dispType -= 40; } if (actor.GetFlagValue("DYNAMICLIGHT.SPOT", false) && dispType < 9840) { dispType += 40; } return(GetLightDataByNum(dispType + baseType)); } else { return(null); } } p = p.BaseClass; } return(null); }
// Constructor public ThingTypeInfo(ThingCategory cat, int index, string title) { string key = index.ToString(CultureInfo.InvariantCulture); // Initialize this.index = index; this.category = cat; this.title = title; this.actor = null; this.isknown = true; this.args = new ArgumentInfo[Linedef.NUM_ARGS]; for (int i = 0; i < Linedef.NUM_ARGS; i++) { this.args[i] = new ArgumentInfo(i); } // Read properties this.sprite = cat.Sprite; this.color = cat.Color; this.arrow = (cat.Arrow != 0); this.radius = cat.Radius; this.height = cat.Height; this.hangs = (cat.Hangs != 0); this.blocking = cat.Blocking; this.errorcheck = cat.ErrorCheck; this.fixedsize = cat.FixedSize; this.absolutez = cat.AbsoluteZ; this.spritescale = new SizeF(cat.SpriteScale, cat.SpriteScale); // Safety if (this.radius < 4f) { this.radius = 8f; } // Make long name for sprite lookup if (this.sprite.Length <= 8) { this.spritelongname = Lump.MakeLongName(this.sprite); } else { this.spritelongname = long.MaxValue; } // We have no destructor GC.SuppressFinalize(this); }
public static int GetGZLightTypeByClass(ActorStructure actor) { int idx = -1; ActorStructure p = actor; while (p != null) { idx = Array.IndexOf(gzLightClasses, p.ClassName.ToLowerInvariant()); if (idx != -1) { // found dynamic light type. alter it by actor flags. // +MISSILEMORE makes it additive. // +MISSILEEVENMORE makes it subtractive. // +INCOMBAT makes it attenuated. int light = gzLights[idx]; if (idx < GZ_LIGHT_TYPES[3]) { int baseType = light % 10; int dispType = light - baseType; if (actor.GetFlagValue("MISSILEMORE", false)) { dispType = 9810; } else if (actor.GetFlagValue("MISSILEEVENMORE", false)) { dispType = 9820; } else if (actor.GetFlagValue("INCOMBAT", false)) { dispType = 9830; } return(dispType + baseType); } else { return(light); } } p = p.BaseClass; } return(0); }
// Constructor internal ThingTypeInfo(int index) { // Initialize this.index = index; this.category = null; this.actor = null; this.title = "<" + index.ToString(CultureInfo.InvariantCulture) + ">"; this.sprite = DataManager.INTERNAL_PREFIX + "unknownthing"; this.classname = string.Empty; //mxd this.color = 0; this.alpha = 1f; //mxd this.alphabyte = 255; //mxd this.renderstyle = "normal"; //mxd this.bright = false; //mxd this.arrow = true; this.radius = 10f; this.renderradius = 10f; this.height = 20f; this.distancechecksq = int.MaxValue; //mxd this.hangs = false; this.blocking = 0; this.errorcheck = 0; this.spritescale = new SizeF(1.0f, 1.0f); this.fixedsize = false; this.fixedrotation = false; //mxd this.spriteframe = new[] { new SpriteFrameInfo { Sprite = sprite, SpriteLongName = Lump.MakeLongName(sprite, true) } }; //mxd this.args = new ArgumentInfo[Linedef.NUM_ARGS]; this.isknown = false; this.absolutez = false; this.xybillboard = false; this.locksprite = false; //mxd this.flagsrename = new Dictionary <string, Dictionary <string, string> >(StringComparer.OrdinalIgnoreCase); //mxd this.thinglink = 0; this.optional = false; // [ZZ] // We have no destructor GC.SuppressFinalize(this); }
// Constructor internal ThingTypeInfo(ThingCategory cat, ActorStructure actor) { // Initialize this.index = actor.DoomEdNum; this.category = cat; this.title = ""; this.actor = actor; this.isknown = true; this.args = new ArgumentInfo[Linedef.NUM_ARGS]; for (int i = 0; i < Linedef.NUM_ARGS; i++) { this.args[i] = new ArgumentInfo(i); } // Read properties this.sprite = cat.Sprite; this.color = cat.Color; this.arrow = (cat.Arrow != 0); this.radius = cat.Radius; this.height = cat.Height; this.hangs = (cat.Hangs != 0); this.blocking = cat.Blocking; this.errorcheck = cat.ErrorCheck; this.fixedsize = cat.FixedSize; this.absolutez = cat.AbsoluteZ; this.spritescale = new SizeF(cat.SpriteScale, cat.SpriteScale); // Safety if (this.radius < 4f) { this.radius = 8f; } // Apply settings from actor ModifyByDecorateActor(actor); // We have no destructor GC.SuppressFinalize(this); }
} //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; } }
// This updates the properties from a decorate actor internal void ModifyByDecorateActor(ActorStructure actor) { ModifyByDecorateActor(actor, false); } //mxd
// Constructor internal ThingTypeInfo(ThingCategory cat, int index, Configuration cfg, IDictionary <string, EnumList> enums) { string key = index.ToString(CultureInfo.InvariantCulture); // Initialize this.index = index; this.category = cat; this.args = new ArgumentInfo[Linedef.NUM_ARGS]; this.isknown = true; this.actor = null; this.bright = false; //mxd this.distancechecksq = int.MaxValue; //mxd // Read properties this.title = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".title", "<" + key + ">"); this.sprite = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".sprite", cat.Sprite); this.color = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".color", cat.Color); this.alpha = General.Clamp(cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".alpha", cat.Alpha), 0f, 1f); //mxd this.alphabyte = (byte)(this.alpha * 255); //mxd this.renderstyle = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".renderstyle", cat.RenderStyle).ToLower(); //mxd this.arrow = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".arrow", cat.Arrow) != 0); this.radius = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".width", cat.Radius); this.height = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".height", cat.Height); this.hangs = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".hangs", cat.Hangs) != 0); this.blocking = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".blocking", cat.Blocking); this.errorcheck = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".error", cat.ErrorCheck); this.fixedsize = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".fixedsize", cat.FixedSize); this.fixedrotation = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".fixedrotation", cat.FixedRotation); //mxd this.absolutez = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".absolutez", cat.AbsoluteZ); float sscale = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".spritescale", cat.SpriteScale); this.spritescale = new SizeF(sscale, sscale); this.locksprite = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".locksprite", false); //mxd this.classname = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".class", String.Empty); //mxd //mxd. Read flagsrename this.flagsrename = new Dictionary <string, Dictionary <string, string> >(StringComparer.OrdinalIgnoreCase); IDictionary maindic = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".flagsrename", new Hashtable()); foreach (DictionaryEntry de in maindic) { string ioname = de.Key.ToString().ToLowerInvariant(); switch (ioname) { case "doommapsetio": case "hexenmapsetio": case "universalmapsetio": IDictionary flagdic = de.Value as IDictionary; if (flagdic == null) { continue; } flagsrename.Add(ioname, new Dictionary <string, string>()); foreach (DictionaryEntry fe in flagdic) { flagsrename[ioname].Add(fe.Key.ToString(), fe.Value.ToString()); } break; default: throw new NotImplementedException("Unsupported MapSetIO"); } } // Read the args for (int i = 0; i < Linedef.NUM_ARGS; i++) { this.args[i] = new ArgumentInfo(cfg, "thingtypes." + cat.Name + "." + key, i, enums); } // Safety if (this.radius < 4f || this.fixedsize) { this.radius = THING_FIXED_SIZE; } if (this.hangs && this.absolutez) { this.hangs = false; //mxd } //mxd. Create sprite frame this.spriteframe = new[] { new SpriteFrameInfo { Sprite = sprite, SpriteLongName = Lump.MakeLongName(sprite, true) } }; // We have no destructor GC.SuppressFinalize(this); }
// Constructor internal StateGoto(ActorStructure actor, DecorateParser parser) { string firsttarget = ""; string secondtarget = ""; bool commentreached = false; bool offsetreached = false; string offsetstr = ""; int cindex = 0; // This is a bitch to parse because for some bizarre reason someone thought it // was funny to allow quotes here. Read the whole line and start parsing this manually. string line = parser.ReadLine(); // Skip whitespace while ((cindex < line.Length) && ((line[cindex] == ' ') || (line[cindex] == '\t'))) { cindex++; } // Parse first target while ((cindex < line.Length) && (line[cindex] != ':')) { // When a comment is reached, we're done here if (line[cindex] == '/') { if ((cindex + 1 < line.Length) && ((line[cindex + 1] == '/') || (line[cindex + 1] == '*'))) { commentreached = true; break; } } // Whitespace ends the string if ((line[cindex] == ' ') || (line[cindex] == '\t')) { break; } // + sign indicates offset start if (line[cindex] == '+') { cindex++; offsetreached = true; break; } // Ignore quotes if (line[cindex] != '"') { firsttarget += line[cindex]; } cindex++; } if (!commentreached && !offsetreached) { // Skip whitespace while ((cindex < line.Length) && ((line[cindex] == ' ') || (line[cindex] == '\t'))) { cindex++; } // Parse second target while (cindex < line.Length) { // When a comment is reached, we're done here if (line[cindex] == '/') { if ((cindex + 1 < line.Length) && ((line[cindex + 1] == '/') || (line[cindex + 1] == '*'))) { commentreached = true; break; } } // Whitespace ends the string if ((line[cindex] == ' ') || (line[cindex] == '\t')) { break; } // + sign indicates offset start if (line[cindex] == '+') { cindex++; offsetreached = true; break; } // Ignore quotes and semicolons if ((line[cindex] != '"') && (line[cindex] != ':')) { secondtarget += line[cindex]; } cindex++; } } // Try to find the offset if we still haven't found it yet if (!offsetreached) { // Skip whitespace while ((cindex < line.Length) && ((line[cindex] == ' ') || (line[cindex] == '\t'))) { cindex++; } if ((cindex < line.Length) && (line[cindex] == '+')) { cindex++; offsetreached = true; } } if (offsetreached) { // Parse offset while (cindex < line.Length) { // When a comment is reached, we're done here if (line[cindex] == '/') { if ((cindex + 1 < line.Length) && ((line[cindex + 1] == '/') || (line[cindex + 1] == '*'))) { commentreached = true; break; } } // Whitespace ends the string if ((line[cindex] == ' ') || (line[cindex] == '\t')) { break; } // Ignore quotes and semicolons if ((line[cindex] != '"') && (line[cindex] != ':')) { offsetstr += line[cindex]; } cindex++; } } // We should now have a first target, optionally a second target and optionally a sprite offset // Check if we don't have the class specified if (string.IsNullOrEmpty(secondtarget)) { // First target is the state to go to classname = actor.ClassName; statename = firsttarget.ToLowerInvariant().Trim(); } else { // First target is the base class to use // Second target is the state to go to classname = firsttarget.ToLowerInvariant().Trim(); statename = secondtarget.ToLowerInvariant().Trim(); } if (offsetstr.Length > 0) { int.TryParse(offsetstr, out spriteoffset); } if ((classname == "super") && (actor.BaseClass != null)) { classname = actor.BaseClass.ClassName; } }
//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(); } }
// This updates the properties from a decorate actor internal void ModifyByDecorateActor(ActorStructure actor) { // Keep reference to actor this.actor = actor; // Set the title if (actor.HasPropertyWithValue("$title")) { title = actor.GetPropertyAllValues("$title"); } else if (actor.HasPropertyWithValue("tag")) { title = actor.GetPropertyAllValues("tag"); } else if (string.IsNullOrEmpty(title)) { title = actor.ClassName; } // Remove doublequotes from title if ((title.Length > 2) && title.StartsWith("\"") && title.EndsWith("\"")) { title = title.Substring(1, title.Length - 2); } // Set sprite string suitablesprite = actor.FindSuitableSprite(); if (!string.IsNullOrEmpty(suitablesprite)) { sprite = suitablesprite; } this.spritelongname = Lump.MakeLongName(this.sprite); // Set sprite scale if (actor.HasPropertyWithValue("scale")) { float scale = actor.GetPropertyValueFloat("scale", 0); this.spritescale = new SizeF(scale, scale); } else { 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); } // Safety if (this.radius < 4f) { this.radius = 8f; } 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; }