static Dictionary <string, LevelBankDescription> ParseFile(string file) { StreamReader reader = new StreamReader(file); try { LevelBankDescription currentDescription = null; Dictionary <string, LevelBankDescription> output = new Dictionary <string, LevelBankDescription>(); while (!reader.EndOfStream) { string line = reader.ReadLine().Split(';')[0].Trim(); if (line.Length == 0) { continue; } if (line[0] == '[' && line[line.Length - 1] == ']') //option beginning { output[line.Substring(1, line.Length - 2)] = currentDescription = new LevelBankDescription(); } else { string[] split = line.Split('='); string cmd = split[0].Trim().ToLower(); if (cmd == "list") //List command { currentDescription.objects = split[1].Trim().Split('|'); } else { currentDescription.commandBytes[cmd] = Array.ConvertAll(split[1].Trim().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), (s) => Array.ConvertAll(s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), (b) => byte.Parse(b.Trim(), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture))); } } } return(output); } finally { reader.Close(); } }
private void cmbBank0x5_0xC_SelectedIndexChanged(object sender, EventArgs e) { lstBankObjects0x5_0xC.DataSource = null; bank0x5 = bankOptions["Bank 0xC.txt"][cmbBank0x5_0xC.Text]; lstBankObjects0x5_0xC.DataSource = bank0x5.objects; }