Beispiel #1
0
        private void shellControl1_CommandEntered(object sender, UILibrary.CommandEnteredEventArgs e)
        {
            var  sg    = ServiceLocator.Get <SavedGame>("SavedGame");
            var  cmd   = Command.Parse(e.Command);
            bool found = false;

            foreach (var x in sg.Commands.ToArray())
            {
                if (x.Key == cmd.Name)
                {
                    foreach (var cm in x.Value)
                    {
                        foreach (var t in Tools)
                        {
                            if (cm.Name == t.Name || t.Name == "*")
                            {
                                t.HandleConsole(shellControl1, cm);
                                found = true;
                            }
                        }
                    }
                }
            }
            foreach (var t in Tools)
            {
                if (t.UseRegex)
                {
                    if (Regex.IsMatch(cmd.Name, t.Name))
                    {
                        t.HandleConsole(shellControl1, cmd);
                        found = true;
                    }
                    else if (t.Name.Contains("*"))
                    {
                        t.HandleConsole(shellControl1, cmd);
                        found = true;
                    }
                }
                else
                {
                    if (cmd.Name == t.Name)
                    {
                        t.HandleConsole(shellControl1, cmd);
                        found = true;
                    }
                    else if (t.Name == "*")
                    {
                        t.HandleConsole(shellControl1, cmd);
                        found = true;
                    }
                }
            }

            if (!found)
            {
                ServiceLocator.Subscribe("LocaleChanged", _ =>
                {
                    Shell.WriteLine(ServiceLocator._("Command not found. Please type 'help' for a List of Commands!"));
                });
            }
        }
Beispiel #2
0
 void shellControl1_CommandEntered(object sender, UILibrary.CommandEnteredEventArgs e)
 {
     _reader.WriteLine(e.Command);
 }