/// <summary> /// Constructor for loading from save game /// </summary> /// <param name="discovered">Discovered string</param> /// <param name="catalogue">Discovery catalogue string</param> public DiscoveryModel(String discovered, String catalogue) { this.discovered = new HashSet <int>(); dc = new DiscoveryCatalogue(catalogue); String[] discoveredElems = discovered.Split(':'); for (int i = 1; i < discoveredElems.Length; i++) { int id; if (int.TryParse(discoveredElems[i], out id)) { this.discovered.Add(id); } } }
public DefaultContentRewriter(IGadgetSpecFactory specFactory, String includeUrls, String excludeUrls, String expires, String includeTags) { this._specFactory = specFactory; this.includeUrls = includeUrls; this.excludeUrls = excludeUrls; this.expires = expires; this.includeTags = new HashSet<string>(); /* foreach */ foreach (String s in includeTags.Split(',')) { if (s != null && s.Trim().Length > 0) { this.includeTags.Add(s.Trim().ToLower()); } } }
public DefaultContentRewriter(IGadgetSpecFactory specFactory, String includeUrls, String excludeUrls, String expires, String includeTags) { this._specFactory = specFactory; this.includeUrls = includeUrls; this.excludeUrls = excludeUrls; this.expires = expires; this.includeTags = new HashSet <string>(); /* foreach */ foreach (String s in includeTags.Split(',')) { if (s != null && s.Trim().Length > 0) { this.includeTags.Add(s.Trim().ToLower()); } } }
protected ContentRewriterFeatureFactory( IGadgetSpecFactory specFactory, String includeUrls, String excludeUrls, String expires, String includeTags) { this.specFactory = specFactory; this.includeUrls = includeUrls; this.excludeUrls = excludeUrls; this.expires = expires; this.includeTags = new HashSet<String>(); foreach(String s in includeTags.Split(',')) { if (s != null && s.Trim().Length > 0) { this.includeTags.Add(s.Trim().ToLower()); } } defaultFeature = new ContentRewriterFeature(null, includeUrls, excludeUrls, expires, this.includeTags); }
protected ContentRewriterFeatureFactory( IGadgetSpecFactory specFactory, String includeUrls, String excludeUrls, String expires, String includeTags) { this.specFactory = specFactory; this.includeUrls = includeUrls; this.excludeUrls = excludeUrls; this.expires = expires; this.includeTags = new HashSet <String>(); foreach (String s in includeTags.Split(',')) { if (s != null && s.Trim().Length > 0) { this.includeTags.Add(s.Trim().ToLower()); } } defaultFeature = new ContentRewriterFeature(null, includeUrls, excludeUrls, expires, this.includeTags); }
/// <summary> /// Constructor for event model from save data /// </summary> /// <param name="usedEvents">String of used events</param> /// <param name="catalogue">String for Event catalogue </param> /// <param name="curEvent">String of current event</param> public EventModel(String usedEvents, String catalogue, String curEvent) { if (curEvent != "") { currentEvent = new Event(curEvent); } else { currentEvent = null; } this.usedEvents = new HashSet <int>(); eventCatalogue = new EventCatalogue(catalogue); String[] usedElems = usedEvents.Split(':'); for (int i = 1; i < usedElems.Length; i++) { int id; if (int.TryParse(usedElems[i], out id)) { this.usedEvents.Add(id); } } }
public void LoadNode(XmlNode node, SchemaNode parent = null) { id = loadString(node, "id"); name = loadString(node, "name"); typeList = loadString(node, "type"); namesFrom = loadString(node, "namesFrom"); category = loadString(node, "category"); schema = loadString(node, "schema"); var scopes = loadString(node, "scope"); var inherits = loadString(node, "inherits"); if (node.Name == "Localized") { typeList = "localized"; } else if (node.Name == "Effect") { inherits = "effect"; typeList = inherits; } else if (node.Name == "Trigger") { inherits = "trigger"; typeList = inherits; } else if (node.Name == "ModifierStack") { inherits = "modifierStack"; typeList = inherits; } else if (node.Name == "Bool") { typeList = "bool"; } else if (node.Name == "Value") { typeList = "value"; } else if (node.Name != "Child") { typeList = node.Name.ToLower(); } if (name == null) { if (typeList == "effect_group") { } name = typeList; } if (typeList == null) { typeList = "none"; } if (inherits != null) { var i = inherits.Split(','); foreach (var s in i) { inheritsIds.Add(s.Trim()); } } if (scopes != null) { var scps = scopes.Split(','); foreach (var scp in scps) { ScopeType scopeEnum; if (Enum.TryParse(scp, out scopeEnum)) { this.scopes.Add(scopeEnum); } } } else { this.scopes.Add(ScopeType.inheritparent); } var targetScope = loadString(node, "targetScope"); ScopeType tsv; Enum.TryParse(targetScope, out tsv); this.targetScope = tsv; function = loadString(node, "function"); requiresData = loadBool(node, "requiresData", false); globalLink = loadBool(node, "globalLink", false); wildcard = loadBool(node, "wildcard", false); allowScopes = loadBool(node, "allowScopes", true); rightHandOnly = loadBool(node, "rightHandOnly", false); avoidRed = loadBool(node, "avoidRed", false); if (typeList.Contains("value")) { inheritsIds.Add("value"); } var c = node.FirstChild; while (c != null) { if (c is XmlComment) { c = c.NextSibling; continue; } var cn = new SchemaNode(); cn.LoadNode(c, this); if (cn.function == "script_list") { var any = new SchemaNode(); cn.copyTo(any); any.name = "any_" + cn.name; children.Add(any); any.inheritsIds.Add("scriptlistTriggerInherits"); any.inheritsIds.Add("trigger"); var random = new SchemaNode(); cn.copyTo(random); random.name = "random_" + cn.name; children.Add(random); random.inheritsIds.Add("scriptlistEffectInherits"); random.inheritsIds.Add("effect"); var every = new SchemaNode(); cn.copyTo(every); every.name = "every_" + cn.name; children.Add(every); every.inheritsIds.Add("scriptlistEffectInherits"); every.inheritsIds.Add("effect"); var ordered = new SchemaNode(); cn.copyTo(ordered); ordered.name = "ordered_" + cn.name; children.Add(ordered); ordered.inheritsIds.Add("scriptlistEffectInherits"); ordered.inheritsIds.Add("effect"); } else { children.Add(cn); } c = c.NextSibling; } if (children.Count > 0 && !children.Any(a => a.name == "scope")) { var cc = SchemaManager.Instance.GetSchema("rhscope").children; children.UnionWith(cc); } if (id != null) { SchemaManager.Instance.AddSchema(id, this); } if (node.Name == "Localized" && parent != null) { var clone = new SchemaNode(); copyTo(clone); clone.inheritsIds.Add("localized"); parent.children.Add(clone); clone.Serialize(); } Serialize(false); }
//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(); } }