/// <summary>Starts the manager and loads all help records into memory</summary> public override void Start() { SystemHost.UpdateSystemHost(this, "Starting..."); string dataRoot = GameConfiguration.DataStoragePath; string helpDir = Path.Combine(dataRoot, "Help"); if (!Directory.Exists(helpDir)) { Directory.CreateDirectory(helpDir); } foreach (string file in Directory.GetFiles(helpDir)) { // We need to read in each line of the file and put it back together explicitly with AnsiSequences.NewLines, // so that we are prepared to send the contents with the expected NewLine of the Telnet protocal, regardless // of what line endings the help file was saved with. var contentLines = File.ReadAllLines(file); string contents = string.Join(AnsiSequences.NewLine, contentLines); // The file name depicts the help topic. Something like "foo_bar" would be a single keyword with an underscore // as part of the help topic alias, while "foo__bar" depicts two aliases ("foo" and "bar"). string nameOnly = Path.GetFileNameWithoutExtension(file); string[] aliases = nameOnly.Split("__"); var helpTopic = new HelpTopic(contents, new List <string>(aliases)); HelpTopics.Add(helpTopic); } SystemHost.UpdateSystemHost(this, "Started"); }
public override OutputBuilder Render(TerminalOptions terminalOptions, HelpTopic helpTopic) { var output = new OutputBuilder(); // TODO: What was this !element doing? Does it still work? Test with zMUD or something and re-read MXP specs? if (terminalOptions.UseMXP) { output.AppendLine($"{AnsiSequences.MxpSecureLine}<!element see '<send href=\"help &cref;\">' att='cref' open>"); } output.AppendSeparator(color: "yellow", design: '='); output.AppendLine($"HELP TOPIC: {helpTopic.Aliases.First()}"); output.AppendSeparator(color: "yellow"); if (terminalOptions.UseMXP) { var lines = helpTopic.Contents.Split(new string[] { AnsiSequences.NewLine }, StringSplitOptions.None); foreach (var line in lines) { output.AppendLine($"{AnsiSequences.MxpOpenLine}{line}<%n%>"); } } else { output.AppendLine($"{helpTopic.Contents}"); } output.AppendSeparator(color: "yellow", design: '='); return(output); }
private void ReloadHelpTopics(string helpDir) { lock (lockObject) { HelpTopics.Clear(); MaxPrimaryAliasLength = 0; foreach (string file in Directory.GetFiles(helpDir)) { // We need to read in each line of the file and put it back together explicitly with AnsiSequences.NewLines, // so that we are prepared to send the contents with the expected NewLine of the Telnet protocal, regardless // of what line endings the help file was saved with. var contentLines = File.ReadAllLines(file); string contents = string.Join(AnsiSequences.NewLine, contentLines); // The file name depicts the help topic. Something like "foo_bar" would be a single keyword with an underscore // as part of the help topic alias, while "foo__bar" depicts two aliases ("foo" and "bar"). string nameOnly = Path.GetFileNameWithoutExtension(file); string[] aliases = nameOnly.Split("__"); var helpTopic = new HelpTopic(contents, new List <string>(aliases)); HelpTopics.Add(helpTopic); } MaxPrimaryAliasLength = (from topic in HelpTopics let primaryAlias = topic.Aliases.FirstOrDefault() where !string.IsNullOrWhiteSpace(primaryAlias) select primaryAlias.Length).Max(); } }
public override string Render(ITerminal terminal, HelpTopic helpTopic) { if (terminal.UseMXP) { var sb = new StringBuilder(); foreach (string line in helpTopic.Contents.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) { sb.AppendLine("<%mxpopenline%>" + line); } return("<%mxpsecureline%><!element see '<send href=\"help &cref;\">' att='cref' open>" + sb.ToString().Trim(Environment.NewLine.ToCharArray())); } else { // TODO: Output without MXP syntax! return("TODO: RENDER TOPIC: " + helpTopic.Contents); } }
public override string Render(ITerminal terminal, HelpTopic helpTopic) { if (terminal.UseMXP) { // TODO: What was this !element doing? Does it still work? Test with zMUD or something and re-read MXP specs? var sb = new StringBuilder("<%mxpsecureline%><!element see '<send href=\"help &cref;\">' att='cref' open>"); sb.Append($"{HeaderLine}HELP TOPIC: {helpTopic.Aliases.First()}{AnsiSequences.NewLine}{HeaderLine}{AnsiSequences.NewLine}"); var lines = helpTopic.Contents.Split(new string[] { AnsiSequences.NewLine }, StringSplitOptions.None); foreach (string line in lines) { sb.Append($"<%mxpopenline%>{line}{AnsiSequences.NewLine}"); } sb.Append("<%n%>"); return(sb.ToString().Trim()); } else { return($"{HeaderLine}HELP TOPIC: {helpTopic.Aliases.First()}{AnsiSequences.NewLine}{HeaderLine}{AnsiSequences.NewLine}{helpTopic.Contents}<%n%>"); } }
/// <summary>Starts the manager and loads all help records into memory</summary> public override void Start() { this.SystemHost.UpdateSystemHost(this, "Starting..."); string dataRoot = Utilities.Configuration.GetDataStoragePath(); string helpDir = Path.Combine(dataRoot, "Help"); if (!Directory.Exists(helpDir)) { Directory.CreateDirectory(helpDir); } foreach (string file in Directory.GetFiles(helpDir)) { string contents = File.ReadAllText(file); string[] fileParts = file.Split(Path.DirectorySeparatorChar); string[] fileAliases = fileParts[fileParts.Length - 1].Split(','); var helpTopic = new HelpTopic(contents, new List <string>(fileAliases)); this.HelpTopics.Add(helpTopic); } this.SystemHost.UpdateSystemHost(this, "Started"); }
public OutputBuilder RenderHelpTopic(TerminalOptions terminalOptions, HelpTopic helpTopic) { return(currentHelpTopicRenderer.Render(terminalOptions, helpTopic)); }
public string RenderHelpTopic(ITerminal terminal, HelpTopic helpTopic) { return(this.currentHelpTopicRenderer.Render(terminal, helpTopic)); }
/// <summary> /// Starts the manager and loads all help records into memory /// </summary> public override void Start() { this.SystemHost.UpdateSystemHost(this, "Starting..."); string dataRoot = Utilities.Configuration.GetDataStoragePath(); string helpDir = Path.Combine(dataRoot, "Help"); if (!Directory.Exists(helpDir)) { Directory.CreateDirectory(helpDir); } foreach (string file in Directory.GetFiles(helpDir)) { string contents = File.ReadAllText(file); string[] fileParts = file.Split(Path.DirectorySeparatorChar); string[] fileAliases = fileParts[fileParts.Length - 1].Split(','); var helpTopic = new HelpTopic(contents, new List<string>(fileAliases)); this.HelpTopics.Add(helpTopic); } this.SystemHost.UpdateSystemHost(this, "Started"); }