Пример #1
0
        private static void checkDir(DirectoryInfo dir)
        {
            if (dir.Exists)
            {
                Console.Title = "StationeersTools - " + dir.Name;

                foreach (FileInfo file in dir.GetFiles())
                {
                    if (file.Name == "world.bin")
                    {
                        raw_binfile = file;
                    }
                    if (file.Name == "world.xml")
                    {
                        raw_xmlfile = file;
                    }
                }

                if (raw_binfile == null || raw_xmlfile == null)
                {
                    PrintUtils.PrintLine("Could not find both world files!", ConsoleColor.Red);
                }
            }
            else
            {
                PrintUtils.PrintLine("Incorrect path!", ConsoleColor.Red);
            }
        }
Пример #2
0
        public static void ShowVoxelSelectMenu(bool heightrequired)
        {
            Console.Clear();
            Console.WriteLine("How would you like to pick the affected area?");

            string[][] options =
            {
                PrintUtils.BuildRow("1", "Circle around point"),
                PrintUtils.BuildRow("2", "Square around point"),
                PrintUtils.BuildRow("3", "Point to point")
            };

            PrintUtils.PrintColumns(options, 1);
            Console.WriteLine();

            int selected = 100;

            while (selected == 100)
            {
                string input = PrintUtils.RequestInputLine("Option");
                int.TryParse(input, out selected);
            }

            BinUtils.StartSelect(selected, heightrequired);
        }
Пример #3
0
        public static Vector3 RequestVector(string message)
        {
            PrintUtils.PrintLine(message, ConsoleColor.DarkYellow);

            Vector3 point = new Vector3();
            bool    fx = false, fy = false, fz = false;

            while (!fx)
            {
                string input = PrintUtils.RequestInputLine("X");
                try
                {
                    point.x = float.Parse(input);
                    fx      = true;
                }
                catch (Exception ex)
                {
                    PrintUtils.PrintLine("Incorrect input!", ConsoleColor.Red);
                }
            }
            while (!fy)
            {
                string input = PrintUtils.RequestInputLine("Y");
                try
                {
                    point.y = float.Parse(input);
                    fy      = true;
                }
                catch (Exception ex)
                {
                    PrintUtils.PrintLine("Incorrect input!", ConsoleColor.Red);
                }
            }
            while (!fz)
            {
                string input = PrintUtils.RequestInputLine("Z");
                try
                {
                    point.z = float.Parse(input);
                    fz      = true;
                }
                catch (Exception ex)
                {
                    PrintUtils.PrintLine("Incorrect input!", ConsoleColor.Red);
                }
            }

            return(point);
        }
Пример #4
0
        public static void FlattenSurface()
        {
            Menus.ShowVoxelSelectMenu(false);

            VoxelUtils.ClearVoxelList(ActiveVoxels);
            Console.Write("Cleared voxels: ");
            PrintUtils.PrintLine(ActiveVoxels.Count.ToString(), ConsoleColor.DarkYellow);

            VoxelUtils.SetVoxelList(FloorVoxels, 1, 255);

            Console.WriteLine("Saving to file...");
            Program.binfile.Save(Program.raw_binfile.FullName);
            Console.Write("Saved! Press any key to continue.");
            Console.Read();
        }
Пример #5
0
        public static float RequestFloat(string message)
        {
            float value = 0;
            bool  fr    = false;

            PrintUtils.PrintLine(message, ConsoleColor.DarkYellow);

            while (!fr)
            {
                string input = PrintUtils.RequestInputLine("Value");
                try
                {
                    value = float.Parse(input);
                    fr    = true;
                }
                catch (Exception ex)
                {
                    PrintUtils.PrintLine("Incorrect input!", ConsoleColor.Red);
                }
            }

            return(value);
        }
Пример #6
0
        static void Main(string[] args)
        {
            Console.Clear();
            PrintUtils.PrepareConsole();
            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
                e.Cancel    = true;
                keepRunning = false;
            };

            Console.WriteLine("Welcome to StationeersTools 2019 - Made by The Psycho");
            Console.WriteLine("You can always press ctrl+c to shut down, this will cancel unsaved changes.");
            Console.WriteLine("Changes will always be written to the original file");
            PrintUtils.PrintLine("Your original file will be backed up, but PLEASE make your own!", ConsoleColor.Red);
            PrintUtils.PrintLine("Although very unlikely, I am not responsible for any damage after game updates.", ConsoleColor.Red);

            if (args.Length > 0)
            {
                try
                {
                    DirectoryInfo dir = new DirectoryInfo(args[0]);
                    checkDir(dir);
                }
                catch (Exception ex)
                {
                    PrintUtils.PrintLine("Incorrect path!", ConsoleColor.Red);
                }
            }
            else
            {
                PrintUtils.PrintLine("Please input the full path to the save folder :)", ConsoleColor.White);

                while (raw_binfile == null || raw_xmlfile == null)
                {
                    try
                    {
                        string dirpath = PrintUtils.RequestInputLine("Directory");

                        DirectoryInfo dir = new DirectoryInfo(dirpath);
                        checkDir(dir);
                    }
                    catch (Exception ex)
                    {
                        PrintUtils.PrintLine("Incorrect path!", ConsoleColor.Red);
                    }
                }
            }

            string datetime = DateTime.Now.ToString("yyyyMMddHmmss");

            raw_binfile.CopyTo(raw_binfile.FullName + "." + datetime + ".original");
            raw_xmlfile.CopyTo(raw_xmlfile.FullName + "." + datetime + ".original");

            LoadFiles();

            while (keepRunning)
            {
                Menus.ShowMenus();

                Console.Clear();
                Console.WriteLine("test");
                Console.ReadKey();
            }

            Console.WriteLine("Graceful Exit");
        }
Пример #7
0
        public static void StartSelect(int type, bool heightrequired)
        {
            if (type == 1)
            {
                Console.Clear();

                Vector3 point  = PrintUtils.RequestVector("Enter coördinates of the center point");
                float   radius = PrintUtils.RequestFloat("Enter radius (length of center to edge)");

                Console.Clear();
                Console.WriteLine("Reading voxels");

                if (heightrequired)
                {
                    float height = PrintUtils.RequestFloat("Please input height");
                    var   res    = VoxelUtils.SelectVoxels(Program.binfile, point, radius, point.y, point.y + height);
                    ActiveVoxels = res.Item1;
                    FloorVoxels  = res.Item2;
                }
                else
                {
                    var res = VoxelUtils.SelectVoxels(Program.binfile, point, radius);
                    ActiveVoxels = res.Item1;
                    FloorVoxels  = res.Item2;
                }
            }
            else if (type == 2)
            {
                Console.Clear();

                Vector3 point = PrintUtils.RequestVector("Enter coördinates of the center point");
                float   range = PrintUtils.RequestFloat("Enter range (length of center to edges)");

                Vector3 min = VectorUtils.GetMinVector(point, range);
                Vector3 max = VectorUtils.GetMaxVector(point, range);
                max.y = 150;

                if (heightrequired)
                {
                    float height = PrintUtils.RequestFloat("Please input height");
                    max.y = min.y + height;
                    var res = VoxelUtils.SelectVoxels(Program.binfile, min, max);
                    ActiveVoxels = res.Item1;
                    FloorVoxels  = res.Item2;
                }
                else
                {
                    var res = VoxelUtils.SelectVoxels(Program.binfile, min, max);
                    ActiveVoxels = res.Item1;
                    FloorVoxels  = res.Item2;
                }

                Console.Clear();
                Console.WriteLine("Reading voxels");
            }
            else if (type == 3)
            {
                Vector3 startpoint = PrintUtils.RequestVector("Enter coördinates of the start point");
                Vector3 endpoint   = PrintUtils.RequestVector("Enter coördinates of the end point");

                Console.Clear();
                Console.WriteLine("Reading voxels");
                var res = VoxelUtils.SelectVoxels(Program.binfile, startpoint, endpoint);
                ActiveVoxels = res.Item1;
                FloorVoxels  = res.Item2;
            }
            else
            {
                Menus.ShowMenus();
            }

            Console.SetCursorPosition(0, 4);
            Console.WriteLine("All applicable voxels found!");
        }