private void BtnDoneClick(object sender, EventArgs e) { char separator = m_cbxSeperator.Text == @"Tabstop (\t)" ? '\t' : '|'; try { Output = CorsixStyleConverter.Parse(m_rtbInput.Lines, separator); } catch (Exception ex) { LoggingManager.SendMessage("Failed to parse RBFConv-style text!"); LoggingManager.HandleException(ex); UIHelper.ShowError("Failed to parse RBFConv-style text: " + ex.Message); return; } if (OnSuccessfulParse != null) { OnSuccessfulParse(); } }
static void ReadLibraryLegacy(StreamReader reader) { string line = reader.ReadLine(); string value = string.Empty; RBFLibEntry currentEntry = null; while (line != null) { if (line.StartsWith("//")) { } else if (line == string.Empty) { if (value != string.Empty && currentEntry != null) { currentEntry.Values = CorsixStyleConverter.Parse(value); } value = string.Empty; } else if (line.StartsWith("[name=")) { line = line.Remove(line.Length - 1, 1).Remove(0, 6); if (currentEntry != null) { if (currentEntry.TagGroups == null) { currentEntry.TagGroups = new string[0]; } if (currentEntry.Tags == null) { currentEntry.Tags = new string[0]; } s_values.Add(currentEntry.Name, currentEntry); } currentEntry = new RBFLibEntry { Name = line }; } else if (line.StartsWith("[tags=")) { line = line.Remove(line.Length - 1, 1).Remove(0, 6); if (line.Length > 0 && currentEntry != null) { currentEntry.Tags = line.Split(s_tagSeperator, StringSplitOptions.RemoveEmptyEntries); } } else if (line.StartsWith("[taggroups=")) { line = line.RemoveLast(1).Remove(0, 11); if (currentEntry != null) { currentEntry.TagGroups = line.Split(s_tagSeperator, StringSplitOptions.RemoveEmptyEntries); } } else if (line.StartsWith("[sub=")) { line = line.Remove(line.Length - 1, 1).Remove(0, 5); if (currentEntry != null) { currentEntry.Submenu = line; } } else { value += line; value += '\n'; } line = reader.ReadLine(); } if (currentEntry != null) { if (value != string.Empty) { currentEntry.Values = CorsixStyleConverter.Parse(value); } if (!s_values.ContainsKey(currentEntry.Name)) { s_values.Add(currentEntry.Name, currentEntry); } } }