public DefaultConnection(IResourceKey rk, RKContainer rkContainer, ResourceDataActions childActions, string absolutePath) : base(rk, absolutePath, childActions) { this.rkContainer = rkContainer; }
public GraphNode(ResourceGraph graph, IResourceKey originalKey, IResourceNode core, PathPackageTuple origin, ResourceDataActions nodeActions, RFileType fileType = RFileType.Unknown) { this.Graph = graph; this.key = new RK(originalKey); this.OriginalKey = new RK(originalKey); this.ExtensionTag = s3pi.Extensions.ExtList.Ext[originalKey.ResourceType][0]; this.NodeActions = nodeActions; this.Core = core; this.Origin = origin; if (fileType == RFileType.Unknown) { this.fileType = ResourceGraph.GetFileType(originalKey.ResourceType); } else { this.fileType = fileType; } switch (this.fileType) { case RFileType.Game: this.name = NameMap.GameNMap.GetName(originalKey.Instance, origin); break; case RFileType.DDS: this.name = NameMap.DDSNMap.GetName(originalKey.Instance, origin); break; case RFileType.Thum: this.name = NameMap.ThumNMap.GetName(originalKey.Instance, origin); break; } this.originalName = this.name; }
/*public override bool SetParentReferenceRK(IResourceKey newKey) * { * string[] fieldNames = this.contentFieldPath.Split(new char[] { '.' }, * StringSplitOptions.RemoveEmptyEntries); * if (fieldNames.Length == 1) * { * IResourceKey rk = this.rootField as IResourceKey; * rk.Instance = newKey.Instance; * } * int i, j, index, indexStrStart, indexStrLength; * TypedValue tv; * string name; * AApiVersionedFields field = this.rootField; * for (i = 1; i < fieldNames.Length; i++) * { * name = fieldNames[i]; * indexStrStart = name.IndexOf('['); * if (indexStrStart == -1) * { * tv = field[name]; * // TODO: Should we account for the possibility of value type resource keys? * if (typeof(IResourceKey).IsAssignableFrom(tv.Type)) * { * IResourceKey rk = tv.Value as IResourceKey; * rk.Instance = newKey.Instance; * field[name] = tv; * return true; * } * if (typeof(TextReader).IsAssignableFrom(tv.Type)) * { * this.textFieldHelper.SetReferenceRK(base.OriginalChildKey, newKey); * field[name] = new TypedValue(tv.Type, this.textFieldHelper.FlushReferenceRKs()); * } * field = tv.Value as AApiVersionedFields; * } * else * { * indexStrLength = name.IndexOf(']'); * if (indexStrLength == -1) * indexStrLength = name.Length - 1 - indexStrStart; * else * indexStrLength = indexStrLength - 1 - indexStrStart; * index = int.Parse(name.Substring(indexStrStart, indexStrLength)); * tv = field[name.Substring(0, indexStrStart)]; * j = -1; * foreach (var e in tv.Value as IEnumerable) * { * if (index == ++j) * { * if (e is IResourceKey) * { * IResourceKey rk = e as IResourceKey; * rk.Instance = newKey.Instance; * return true; * } * else if (e is IEnumerable) * { * IEnumerable list = e as IEnumerable; * string suffix = name.Substring(indexStrStart + indexStrLength + 1); * indexStrStart = suffix.IndexOf('['); * while (indexStrStart != -1) * { * indexStrLength = suffix.IndexOf(']'); * if (indexStrLength == -1) * indexStrLength = suffix.Length - 1 - indexStrStart; * else * indexStrLength = indexStrLength - 1 - indexStrStart; * int subIndex = int.Parse(suffix.Substring(indexStrStart, indexStrLength)); * int k = -1; * foreach (var f in list) * { * if (index == ++k) * { * if (f is IResourceKey) * { * IResourceKey rk = f as IResourceKey; * rk.Instance = newKey.Instance; * return true; * } * else if (f is IEnumerable) * { * list = f as IEnumerable; * suffix = suffix.Substring(indexStrStart + indexStrLength + 1); * indexStrStart = suffix.IndexOf('['); * } * else * { * field = f as AApiVersionedFields; * } * } * } * } * } * else * { * field = e as AApiVersionedFields; * } * } * } * } * } * return false; * }/**/ public DefaultConnection(IResourceKey rk, AApiVersionedFields rkField, ResourceDataActions childActions, string absolutePath, string rkFieldPath = "root", Predicate <IResourceKey> validate = null) : base(rk, absolutePath, childActions) { this.rkContainer = new RKContainer(rkFieldPath, rkField, absolutePath, validate); }
public AResourceConnection(IResourceKey childKey, string path, ResourceDataActions childActions) { this.absolutePath = path; this.originalChildKey = childKey; this.childDataActions = childActions; this.isChildDDS = ResourceGraph.IsDDS(childKey.ResourceType); this.isChildThum = ResourceGraph.IsThum(childKey.ResourceType); }
/*public override bool SetParentReferenceRK(IResourceKey newKey) { string[] fieldNames = this.contentFieldPath.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (fieldNames.Length == 1) { IResourceKey rk = this.rootField as IResourceKey; rk.Instance = newKey.Instance; } int i, j, index, indexStrStart, indexStrLength; TypedValue tv; string name; AApiVersionedFields field = this.rootField; for (i = 1; i < fieldNames.Length; i++) { name = fieldNames[i]; indexStrStart = name.IndexOf('['); if (indexStrStart == -1) { tv = field[name]; // TODO: Should we account for the possibility of value type resource keys? if (typeof(IResourceKey).IsAssignableFrom(tv.Type)) { IResourceKey rk = tv.Value as IResourceKey; rk.Instance = newKey.Instance; field[name] = tv; return true; } if (typeof(TextReader).IsAssignableFrom(tv.Type)) { this.textFieldHelper.SetReferenceRK(base.OriginalChildKey, newKey); field[name] = new TypedValue(tv.Type, this.textFieldHelper.FlushReferenceRKs()); } field = tv.Value as AApiVersionedFields; } else { indexStrLength = name.IndexOf(']'); if (indexStrLength == -1) indexStrLength = name.Length - 1 - indexStrStart; else indexStrLength = indexStrLength - 1 - indexStrStart; index = int.Parse(name.Substring(indexStrStart, indexStrLength)); tv = field[name.Substring(0, indexStrStart)]; j = -1; foreach (var e in tv.Value as IEnumerable) { if (index == ++j) { if (e is IResourceKey) { IResourceKey rk = e as IResourceKey; rk.Instance = newKey.Instance; return true; } else if (e is IEnumerable) { IEnumerable list = e as IEnumerable; string suffix = name.Substring(indexStrStart + indexStrLength + 1); indexStrStart = suffix.IndexOf('['); while (indexStrStart != -1) { indexStrLength = suffix.IndexOf(']'); if (indexStrLength == -1) indexStrLength = suffix.Length - 1 - indexStrStart; else indexStrLength = indexStrLength - 1 - indexStrStart; int subIndex = int.Parse(suffix.Substring(indexStrStart, indexStrLength)); int k = -1; foreach (var f in list) { if (index == ++k) { if (f is IResourceKey) { IResourceKey rk = f as IResourceKey; rk.Instance = newKey.Instance; return true; } else if (f is IEnumerable) { list = f as IEnumerable; suffix = suffix.Substring(indexStrStart + indexStrLength + 1); indexStrStart = suffix.IndexOf('['); } else { field = f as AApiVersionedFields; } } } } } else { field = e as AApiVersionedFields; } } } } } return false; }/**/ public DefaultConnection(IResourceKey rk, AApiVersionedFields rkField, ResourceDataActions childActions, string absolutePath, string rkFieldPath = "root", Predicate<IResourceKey> validate = null) : base(rk, absolutePath, childActions) { this.rkContainer = new RKContainer(rkFieldPath, rkField, absolutePath, validate); }