public static void WriteWarning(VText warning) { warning = Text("WARNING: ").Plus(warning); warning.Apply(VTextTransform.SetForeground(ColorStandards.Warning, true)); Log.Add(warning.ToString(), Log.MessageType.Warning); Console.WriteLine(warning); }
public static void WriteDebug(VText debug) { debug = Text("DEBUG: ").Plus(debug); debug.Apply(VTextTransform.SetForeground(ColorStandards.Debug, true)); Log.Add(debug.ToString(), Log.MessageType.Debug); Console.WriteLine(debug); }
public static void WriteError(VText error, bool deadly = false) { error = Text("ERROR: ").Plus(error); error = error.Apply(VTextTransform.SetForeground(ColorStandards.Error, true)); Log.Add(error.ToString(), Log.MessageType.Error); Console.WriteLine(error); }
public CommandBuilder WithYesNoAction(Action <Game, Command> action) { var forceTag = new Tag("-f", Text("Forces command to go through")); if (_tags == null) { _tags = new List <Tag>(); } _tags.Add(forceTag); _actions.Add((game, command) => { if (command.UsedTags.Contains(forceTag)) { //Forced action(game, command); } else { var question = Text("Are you sure you want to ") + command.Description + Text("? (yes/no)"); if (YesNoLoop.Get(game, question.Apply(VTextTransform.SetForeground(VColor.Gold)))) { action(game, command); } } }); return(this); }
public override bool Fill(string input) { try { Content = int.Parse(input); IsNull = false; return(true); } catch (FormatException) { WriteError(Name + Text(" needs an integer argument. (Received ") + Text(input).Apply(VTextTransform.Quote()).Apply(VTextTransform.SetForeground(ColorStandards.Input)) + Text(")")); return(false); } }
public override bool Fill(string input) { if (input.ToLower().StartsWith("f")) { Content = false; IsNull = false; } else if (input.ToLower().StartsWith("t")) { Content = true; IsNull = false; } else { WriteError(Name + Text(" needs a boolean argument. (Received ") + Text(input).Apply(VTextTransform.Quote()).Apply(VTextTransform.SetForeground(ColorStandards.Input)) + Text(")")); IsNull = true; } return(!IsNull); }
private static void DisplayCommand(Game game, Command command) { game.AddElement(new TitleElement(command)); WriteLine(command.Description.Apply(VTextTransform.Capitalize())); var usage = Text("Usage: ") + command; foreach (var argument in command.Arguments) { usage += Text(" ") + argument.Apply(VTextTransform.Quote("[", "]")) .Apply(VTextTransform.SetForeground(ColorStandards.Argument)); } foreach (var argument in command.OptionalArguments) { usage += Text(" ") + argument.Apply(VTextTransform.Quote("(", ")")) .Apply(VTextTransform.SetForeground(ColorStandards.Optional)); } WriteLine(usage); if (command.Arguments.Count > 0 || command.OptionalArguments.Count > 0) { WriteLine(Text("Arguments:", ColorStandards.Title)); } foreach (var argument in command.Arguments) { WriteLine(Text(" ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Argument)) + Text(": ") + argument.Description); } foreach (var argument in command.OptionalArguments) { WriteLine(Text(" ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Optional)) + Text(": ") + argument.Description); } if (command.Tags.Count > 0) { WriteLine(Text("Tags:", ColorStandards.Title)); } foreach (var tag in command.Tags) { VText tagUsage = Text(" ") + tag; foreach (var argument in tag.Arguments) { tagUsage += Text(" ") + argument.Apply(VTextTransform.Quote("[", "]")) .Apply(VTextTransform.SetForeground(ColorStandards.Argument)); } foreach (var argument in tag.OptionalArguments) { tagUsage += Text(" ") + argument.Apply(VTextTransform.Quote("(", ")")) .Apply(VTextTransform.SetForeground(ColorStandards.Argument)); } WriteLine(tagUsage); WriteLine(Text(" ") + tag.Description); foreach (var argument in tag.Arguments) { WriteLine(Text(" ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Argument)) + Text(": ") + argument.Description); } foreach (var argument in tag.OptionalArguments) { WriteLine(Text(" ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Optional)) + Text(": ") + argument.Description); } } }