private static void WriteMaterialValuesToFile(string folderPath) { var enumValues = Enum.GetNames(typeof(SSBHLib.Formats.Materials.MatlEnums.ParamId)); var valuesByParamId = new Dictionary <SSBHLib.Formats.Materials.MatlEnums.ParamId, HashSet <string> >(); var outputByParamId = new Dictionary <SSBHLib.Formats.Materials.MatlEnums.ParamId, System.Text.StringBuilder>(); foreach (var file in Directory.EnumerateFiles(folderPath, "*numatb", SearchOption.AllDirectories)) { var matl = new MATL_Node(file); matl.Open(); foreach (var entry in matl.Material.Entries) { foreach (var attribute in entry.Attributes) { string text = $"{attribute.ParamID} {attribute.DataObject} {file.Replace(folderPath, "")}"; if (!outputByParamId.ContainsKey(attribute.ParamID)) { outputByParamId.Add(attribute.ParamID, new System.Text.StringBuilder()); } if (!valuesByParamId.ContainsKey(attribute.ParamID)) { valuesByParamId.Add(attribute.ParamID, new HashSet <string>()); } // Don't check duplicates for booleans. if (attribute.DataType == SSBHLib.Formats.Materials.MatlEnums.ParamDataType.Boolean) { outputByParamId[attribute.ParamID].AppendLine(text); } else if (!valuesByParamId.ContainsKey(attribute.ParamID) || !valuesByParamId[attribute.ParamID].Contains(attribute.DataObject.ToString())) { outputByParamId[attribute.ParamID].AppendLine(text); valuesByParamId[attribute.ParamID].Add(attribute.DataObject.ToString()); } } } } foreach (var pair in outputByParamId) { File.WriteAllText($"{pair.Key}_unique_values.txt", pair.Value.ToString()); } }
private void printMaterialValuesToolStripMenuItem_Click(object sender, EventArgs e) { string folderPath = FileTools.TryOpenFolder("Select Source Directory"); if (string.IsNullOrEmpty(folderPath)) { return; } uint paramId = Rendering.RenderSettings.Instance.ParamId; var values = new System.Collections.Generic.HashSet <string>(); var outputText = new System.Text.StringBuilder(); foreach (var file in Directory.EnumerateFiles(folderPath, "*numatb", SearchOption.AllDirectories)) { var matl = new MATL_Node(); matl.Open(file); foreach (var entry in matl.Material.Entries) { foreach (var attribute in entry.Attributes) { if ((uint)attribute.ParamID == paramId) { string text = $"{paramId.ToString("X")} {attribute.DataObject} {file.Replace(folderPath, "")}"; if (!values.Contains(attribute.DataObject.ToString())) { outputText.AppendLine(text); values.Add(attribute.DataObject.ToString()); } } } } } File.WriteAllText("output.txt", outputText.ToString()); }