public void Run(string[] args)
        {
            if (args.Length == 3)
            {
                String key           = args[1];
                String realValue     = SVars.getValue <String>(key);
                String expectedValue = args[2];

                if (realValue == null)
                {
                    Console.WriteLine("The value of key: '" + key + "'  has not been set, or is not a String.");
                    return;
                }
                bool eq = expectedValue.Equals(realValue);
                if (eq)
                {
                    Console.WriteLine("Yes, the value:'" + realValue + " of key: '" + key + "' is equal to the given value: '" + expectedValue + "'.");
                }
                else
                {
                    Console.WriteLine("No, the value:'" + realValue + " of key: '" + key + "' is not equal to the given value: '" + expectedValue + "'.");
                }
            }
            else
            {
                Console.WriteLine("{0} arguments expected, only {1} was/were given", 2, args.Length - 1);
            }
        }
Beispiel #2
0
        public void Run(string[] args)
        {
            String axis = SVars.getValue <String>("echo_axis");

            if (axis.Equals("vertical"))
            {
                for (int i = 1; i < args.Length; i++)
                {
                    Console.WriteLine(args[i]);
                }
            }
            else
            {
                for (int i = 1; i < args.Length; i++)
                {
                    Console.Write(args[i]);
                    if (i < args.Length - 1)
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
                if (!axis.Equals("horizontal"))
                {
                    Console.WriteLine("Variable 'echo_axis' is not a known value, known values are: horizontal, vertical." +
                                      "\nResorting to defualt value: horizontal.");
                }
            }
        }
Beispiel #3
0
        public void Run(string[] args)
        {
            String path = null;

            if (args.Length == 1)
            {
                path = SVars.getValue <String>("game");
            }
            else if (args.Length > 1)
            {
                path = args[1];
            }

            if (!File.Exists(path))
            {
                Console.WriteLine("The executable was not found in path: " + path);
                return;
            }

            ProcessStartInfo gameStart = new ProcessStartInfo();

            gameStart.FileName         = Path.GetFileName(path);
            gameStart.WorkingDirectory = Path.GetDirectoryName(path);

            Console.WriteLine("Starting process at: \"" + path + "\"");
            Process game = Process.Start(gameStart);

            game.EnableRaisingEvents = true;
            game.Exited += GameClosed;
            runningGames.Add(game);

            String storrageDir = "giraffe_storage"; //MAYBE: make this configurable
            String logfile     = "starbound.log";
            String logPath     = Directory.GetParent(Path.GetDirectoryName(path)).FullName + Path.DirectorySeparatorChar + storrageDir +
                                 Path.DirectorySeparatorChar + logfile;

            ProcessStartInfo consoleStart = new ProcessStartInfo();

            consoleStart.Arguments = "\"" + logPath + "\"";
            consoleStart.FileName  = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) +
                                     Path.DirectorySeparatorChar + "FileListener.exe";

            Process externConsole = Process.Start(consoleStart);

            externConsole.EnableRaisingEvents = true;
            externConsole.Exited += ConsoleClosed;
            runningConsoles.Add(externConsole);
        }
        //LOOKAT: Check if key doesnt have ':' in it.
        //MAYBE: Find more dangerous chars
        //TODO: Save booleans differently
        void Save(String name, String file)
        {
            List <String> l;

            if (configs.TryGetValue(name, out l))
            {
                using (StreamWriter sw = File.CreateText(file)) {
                    try {
                        foreach (String s in l)
                        {
                            sw.WriteLine(s + ":" + SVars.getValue <object>(s)?.ToString());
                        }
                        Console.WriteLine("Succesfully saved config: " + name + " to file: " + file);
                    } catch (IOException ex) {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            else
            {
                Console.WriteLine("Could not find config: " + name);
            }
        }
Beispiel #5
0
 public void Run(string[] args)
 {
     if (args.Length == 1)
     {
         Console.WriteLine(Name + " - " + Description);
         return;
     }
     if (args.Length > 2 && args[1].Equals("get"))
     {
         Console.WriteLine(SVars.getValue <Object>(args[2])?.ToString());
     }
     if (args.Length > 3 && args[1].Equals("set"))//LOOKAT: add solution of other types, ex: Booleans
     {
         if (SVars.getValue <object>(args[2]) != null)
         {
             SVars.Change(args[2], args[3]);
         }
         else
         {
             SVars.Register(args[2], args[3]);
         }
     }
 }
        //TODO: Load Booleans differently
        void Load(String file, String name)
        {
            if (configs.ContainsKey(name))
            {
                Console.WriteLine("Config: " + name + " already exists");
            }
            else
            {
                try {
                    using (StreamReader sw = File.OpenText(file)) {
                        List <String> keys = new List <string>();
                        for (String line = sw.ReadLine(); line != null; line = sw.ReadLine())
                        {
                            int split = line.IndexOf(':');
                            if (split != -1)
                            {
                                String key   = line.Substring(0, split);
                                String value = line.Substring(split + 1);
                                keys.Add(key);
                                SVars.Add(key, value);
                            }
                            else
                            {
                                Console.WriteLine("line in file {0} is not standard", file);
                            }

                            line = sw.ReadLine();
                        }
                        configs.Add(name, keys);
                        Console.WriteLine("Succesfully loaded config: " + name + " to file: " + file);
                    }
                } catch (IOException ex) {
                    Console.WriteLine("Something went wront loading: {0}", ex.Message);
                }
            }
        }
 public void Run(string[] args)
 {
     SVars.Change("exit", true);
 }
Beispiel #8
0
 public Echo()
 {
     SVars.Register("echo_axis", "horizontal");
 }