private static string ExecuteDeleteTPKSTR(BasicBase db, string root, string node, string hash) { switch (root) { case TPKBlocks: if (!db.TryGetCollection(node, root, out var inter)) { return($"Collection {node} cannot be found in root {root}."); } if (!(inter is TPKBlock tpk)) { return($"Collection {node} is not a {STRBlocks} collection."); } if (tpk.TryRemoveTexture(ConvertX.ToUInt32(hash), eKeyType.BINKEY, out var error)) { return(null); } else if (Settings.Default.EnableSuppressABCI) { return(null); } else { return(error); } case STRBlocks: if (!db.TryGetCollection(node, root, out var collection)) { return($"Collection {node} cannot be found in root {root}."); } if (!(collection is STRBlock str)) { return($"Collection {node} is not a {STRBlocks} collection."); } if (str.TryRemoveRecord(hash, out var fail)) { return(null); } else if (Settings.Default.EnableSuppressABCI) { return(null); } else { return(fail); } default: return($"Invalid root passed named {root}."); } }
private static string ExecuteUpdateTPKSTR(BasicBase db, string root, string node, string hash, string field, string value) { switch (root) { case TPKBlocks: if (!db.TryGetCollection(node, root, out var inter)) { return($"Collection {node} cannot be found in root {root}."); } if (!(inter is TPKBlock tpk)) { return($"Collection {node} is not a {STRBlocks} collection."); } var texture = tpk.FindTexture(ConvertX.ToUInt32(hash), eKeyType.BINKEY); if (texture == null) { return($"Texture with key {hash} does not exist in {node}"); } string error = null; texture.SetValue(field, value, ref error); return(error); case STRBlocks: if (!db.TryGetCollection(node, root, out var collection)) { return($"Collection {node} cannot be found in root {root}."); } if (!(collection is STRBlock str)) { return($"Collection {node} is not a {STRBlocks} collection."); } var record = str.GetRecord(hash); if (record == null) { return($"StringRecord with key {hash} does not exist."); } if (!record.TrySetValue(field, value)) { return($"Unable to set value {value} in field {field} specified."); } else { return(null); } default: return($"Invalid root passed named {root}."); } }
private static string ExecuteAddTexture(BasicBase db, string root, string node, string path) { if (!db.TryGetCollection(node, root, out var collection)) { return($"Collection {node} cannot be found in root {root}."); } if (!(collection is TPKBlock tpk)) { return($"Collection {node} is not a {root} collection."); } if (!File.Exists(path)) { return($"File named {path} does not exist."); } if (tpk.TryAddTexture(Path.GetFileNameWithoutExtension(path), path, out var error)) { return(null); } else if (Settings.Default.EnableSuppressABCI) { return(null); } else { return(error); } }
private static string ExecuteUpdateCollection(BasicBase db, string root, string node, string field, string value) { if (root == FNGroups) { return(ExecuteUpdateFNG(db, node, field, value)); } string error = null; if (!db.TryGetCollection(node, root, out var collection)) { return($"Collection {node} cannot be found in root {root}."); } if (collection.SetValue(field, value, ref error)) { return(null); } else { return(error); } }
private static string ExecuteReplaceTexture(BasicBase db, string root, string node, string hash, string path) { if (!db.TryGetCollection(node, root, out var collection)) { return($"Collection {node} cannot be found in root {root}."); } if (!(collection is TPKBlock tpk)) { return($"Collection {node} is not a {STRBlocks} collection."); } if (!File.Exists(path)) { return($"File named {path} does not exist."); } if (tpk.TryReplaceTexture(ConvertX.ToUInt32(hash), eKeyType.BINKEY, path, out var error)) { return(null); } else { return(error); } }
private static string ExecuteCopyTexture(BasicBase db, string root, string node, string hash, string cname) { if (!db.TryGetCollection(node, root, out var collection)) { return($"Collection {node} cannot be found in root {root}."); } if (!(collection is TPKBlock tpk)) { return($"Collection {node} is not a {STRBlocks} collection."); } if (tpk.TryCloneTexture(cname, ConvertX.ToUInt32(hash), eKeyType.BINKEY, out var error)) { return(null); } else if (Settings.Default.EnableSuppressABCI) { return(null); } else { return(error); } }
private static string ExecuteAddString(BasicBase db, string root, string node, string key, string label, string text) { if (!db.TryGetCollection(node, root, out var collection)) { return($"Collection {node} cannot be found in root {root}."); } if (!(collection is STRBlock str)) { return($"Collection {node} is not a {STRBlocks} collection."); } if (str.TryAddRecord(key, label, text, out var error)) { return(null); } else if (Settings.Default.EnableSuppressABCI) { return(null); } else { return(error); } }
private static string ExecuteUpdateFNG(BasicBase db, string node, string field, string value) { if (!db.TryGetCollection(node, FNGroups, out var collection)) { return($"Collection {node} does not exist in root {FNGroups}."); } if (!(collection is FNGroup fng)) { return($"Collection {node} is not a {FNGroups} collection."); } if (!SAT.CanBeColor(value)) { return($"Value {value} is not an 8-digit hexadecimal color-type."); } var color = new FEngColor(null); color.Alpha = SAT.GetAlpha(value); color.Red = SAT.GetRed(value); color.Green = SAT.GetGreen(value); color.Blue = SAT.GetBlue(value); if (field.StartsWith("ReplaceSame")) { if (field.StartsWith("ReplaceSameNoAlpha[") && field.EndsWith("]")) { if (FormatX.GetInt32(field, "ReplaceSameNoAlpha[{X}]", out int index)) { fng.TrySetSame(index, color, true); } else { return($"Unable to get color index from field named {field}."); } } else if (field.StartsWith("ReplaceSameWithAlpha[") && field.EndsWith("]")) { if (FormatX.GetInt32(field, "ReplaceSameWithAlpha[{X}]", out int index)) { fng.TrySetSame(index, color, false); } else { return($"Unable to get color index from field named {field}."); } } else { return($"Incorrect passed parameter named {field}."); } } else if (field == "ReplaceAllNoAlpha") { fng.TrySetAll(color, true); } else if (field == "ReplaceAllWithAlpha") { fng.TrySetAll(color, false); } else { int index = SAT.GetIndex(field); if (index >= fng.InfoLength || index == -1) { return($"Field named {field} does not exist."); } fng.TrySetOne(index, color); } return(null); }