Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var city = Prompt.Select("Select your city", new[] { "Seattle", "London", "Tokyo" });

            Console.WriteLine($"Hello, {city}!");
            var answer = Prompt.Confirm("Are you ready?");

            Console.WriteLine($"Your answer is {answer}");
        }
Exemple #2
0
 static void Main(string[] args)
 {
     while (true)
     {
         var processes = Process.GetProcesses().ToList().ToDictionary(i => $"{i.ProcessName} {i.Id}", i => i);
         var ps        = Prompt.Select("Select Process", processes.Keys, 15);
         if (Prompt.Confirm("Are you sure to end " + ps, true))
         {
             processes[ps].Kill();
         }
     }
 }
Exemple #3
0
        static void Main(string[] args)
        {
            var name = Prompt.Input <string>("What's your name?", validators: new[] { Validators.Required() });

            Console.WriteLine($"Hello, {name}!");

            var city = Prompt.Select("Select your city", new[] { "Seattle", "London", "Tokyo", "New York", "Singapore", "Shanghai" }, pageSize: 3);

            Console.WriteLine($"Hello, {city}!");

            var secret = Prompt.Password("Type new password", new[] { Validators.Required(), Validators.MinLength(8) });

            Console.WriteLine("Password OK");

            var answer = Prompt.Confirm("Are you ready?");

            Console.WriteLine($"Your answer is {answer}");
        }
Exemple #4
0
        /// <summary>
        /// Outputs the maze to a text file
        /// </summary>
        /// <param name="maze">A ready made maze</param>
        private void OutputToFile(Maze maze)
        {
            var inputFileName = Prompt.Input <string>(MenuPrompt.SAVE_INPUT_FILE_NAME);

            if (inputFileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
            {
                Console.WriteLine(Error.INVALID_FILE_NAME + Environment.NewLine,
                                  inputFileName);
                if (!Prompt.Confirm(MenuConfirm.ENTER_AGAIN))
                {
                    OutputToFile(maze);
                    return;
                }
                else
                {
                    return;
                }
            }
            if (!inputFileName.Contains(Default.TXT_FILE_EXTENSION))//Add the .mze eztension if not present.
            {
                inputFileName += Default.TXT_FILE_EXTENSION;
            }
            string fileNameLocation = Default.TXT_FILE_FOLDER + inputFileName; //puts the file in the default folder

            if (File.Exists(fileNameLocation))                                 //Checks if file already exists.
            {
                Console.WriteLine(Error.SAVE_FILE_EXISTS + Environment.NewLine,
                                  Default.TXT_FILE_FOLDER + inputFileName);
                if (!Prompt.Confirm(MenuConfirm.OVERWRITE))
                {
                    OutputToFile(maze);
                    return;
                }
                File.Delete(Default.TXT_FILE_FOLDER + fileNameLocation);
            }
            Console.WriteLine(Progress.SAVE + Environment.NewLine,
                              fileNameLocation);
            using StreamWriter file = File.CreateText(fileNameLocation);
            file.WriteLine(maze.Display());
            Console.WriteLine(Progress.SUCCESS_SAVE + Environment.NewLine,
                              Default.TXT_FILE_FOLDER + inputFileName);
            file.Close();
        }
Exemple #5
0
        /// <summary>
        /// Saves the maze to a json file
        /// </summary>
        /// <param name="maze">A ready made maze</param>
        private void SaveToFile(Maze maze)
        {
            var inputFileName = Prompt.Input <string>(MenuPrompt.SAVE_INPUT_FILE_NAME);

            if (inputFileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
            {
                Console.WriteLine(Error.INVALID_FILE_NAME + Environment.NewLine,
                                  inputFileName);
                if (!Prompt.Confirm(MenuConfirm.ENTER_AGAIN))
                {
                    OutputToFile(maze);
                    return;
                }
                else
                {
                    return;
                }
            }
            if (!inputFileName.Contains(Default.MZE_FILE_EXTENSION))//Add the .mze eztension if not present.
            {
                inputFileName += Default.MZE_FILE_EXTENSION;
            }
            if (File.Exists(Default.MZE_FILE_FOLDER + inputFileName))//Checks if file already exists.
            {
                Console.WriteLine(Error.SAVE_FILE_EXISTS + Environment.NewLine,
                                  inputFileName);
                if (!Prompt.Confirm(MenuConfirm.OVERWRITE))
                {
                    SaveToFile(maze);
                    return;
                }
                File.Delete(Default.MZE_FILE_FOLDER + inputFileName);
            }
            Console.WriteLine(Progress.SAVE,
                              Default.MZE_FILE_FOLDER + inputFileName);
            using StreamWriter file = File.CreateText(Default.MZE_FILE_FOLDER + inputFileName);
            JsonSerializer serializer = new JsonSerializer();

            serializer.Serialize(file, maze);
            Console.WriteLine(Progress.SUCCESS_SAVE + Environment.NewLine,
                              Default.MZE_FILE_FOLDER + inputFileName);
            file.Close();
        }
 private void frmAssessment_FormClosing(object sender, FormClosingEventArgs e)
 {
     //added 20101006 - check detail windows
     if (!WindowOpen(discountDetails) && !WindowOpen(paymentDetails))
     {
         if (transaction != null)
         {
             if (Prompt.Confirm(transaction.DocumentNumber +
                                " is modified. Discard changes?")
                 == DialogResult.Yes)
             {
                 e.Cancel = false;
             }
             else
             {
                 e.Cancel = true;
             }
         }
     }
     else
     {
         e.Cancel = true;
     }
 }
Exemple #7
0
        private static void RunConfirmSample()
        {
            var answer = Prompt.Confirm("Are you ready?");

            Console.WriteLine($"Your answer is {answer}");
        }
Exemple #8
0
        static void Main(string[] args)
        {
            // save colors to restore at the end
            var(fgColor, bgColor) = (ForegroundColor, BackgroundColor);

            _isSingleFile = CheckOptionAndRemove(ref args, "--single-file");

            _zipFiles = CheckOptionAndRemove(ref args, "--zip");

            if (args.Length > 0)
            {
                if (new[] { "debug", "rel" }.Any(c => c == args[0]))
                {
                    args[0] = args[0] + ":any";
                }
            }

            Target("clean", "Delete the {project}/bin and {project}/obj directories.",
                   () => DeleteDirs($"{PROJECT_DIR}/bin", $"{PROJECT_DIR}/obj"));

            Target("clean:all", "Calls clean and then also deletes the /dist directory",
                   DependsOn("clean"),
                   () => DeleteDirs(OUTPUT_DIR));

            Target("default", "Runs the rel:any target", DependsOn("rel:any"));

            Target("debug:all", $"Builds all debug targets: any, linux, macos & win10",
                   DependsOn("clean:all", "debug:any", "debug:linux", "debug:macos", "debug:win10"));

            Target("debug:any", "Debug release that should run on any platform where .NET 5 runtime is installed.",
                   DependsOn("clean"),
                   () => Publish(DEFAULT_RUNTIME, DEBUG_CONFIG));

            Target("debug:linux", "Self contained debug release targeting Linux.",
                   DependsOn("clean"),
                   () => Publish("linux-x64", DEBUG_CONFIG));

            Target("debug:macos", $"Self contained debug release targeting Apple macOS.",
                   DependsOn("clean"),
                   () => Publish("osx-x64", DEBUG_CONFIG));

            Target("debug:win10", "Self contained debug release targeting Microsoft Windows 10.",
                   DependsOn("clean"),
                   () => Publish("win10-x64", DEBUG_CONFIG));

            Target("prompt", "Interactive mode that will ask for build options.", () => {
                var config = Prompt.Select("Select build configuration"
                                           , new[] { DEBUG_CONFIG, RELEASE_CONFIG }
                                           , defaultValue: DEBUG_CONFIG);
                var runtime = Prompt.Select("Select target runtime"
                                            , new[] { DEFAULT_RUNTIME, "linux-x64", "macos-x64", "win10-x64" }
                                            , defaultValue: DEFAULT_RUNTIME);
                _isSingleFile = (runtime != DEFAULT_RUNTIME) &&
                                Prompt.Confirm("Set the PublishSingleFile property to true?", defaultValue: false);
                _zipFiles = Prompt.Confirm("Move files to a zip file after the build?", false);
                if (Prompt.Confirm("Proceed with above values?", defaultValue: true))
                {
                    Publish(runtime, config);
                }
            });

            Target("rel:all", $"Builds all release targets: any, linux, macos & win10",
                   DependsOn("clean:all", "rel:any", "rel:linux", "rel:macos", "rel:win10"));

            Target("rel:any", "Release that should run on any platform where .NET 5 runtime is installed.",
                   DependsOn("clean"),
                   () => Publish(DEFAULT_RUNTIME, RELEASE_CONFIG));

            Target("rel:linux", "Self contained release targeting Linux.",
                   DependsOn("clean"),
                   () => Publish("linux-x64", RELEASE_CONFIG));

            Target("rel:macos", $"Self contained release targeting Apple macOS.",
                   DependsOn("clean"),
                   () => Publish("osx-x64", RELEASE_CONFIG));

            Target("rel:win10", "Self contained release targeting Microsoft Windows 10.",
                   DependsOn("clean"),
                   () => Publish("win10-x64", RELEASE_CONFIG));

            Target("tool:check", "Checks packages and lists those that have a newer version,\n               have been deprecated or have known vulnerabilities.",
                   () => {
                string[] checkPackageOptions = new[] {
                    "--outdated", "--deprecated", "--vulnerable --include-transitive"
                };

                void RunChecks(string prjDir)
                {
                    foreach (var option in checkPackageOptions)
                    {
                        WriteLine($"\n>>> Checking for {option.Split(' ')[0][2..]} packages");
                        Run("dotnet", $"list {prjDir} package {option}");
                    }
Exemple #9
0
        private static void InteractiveMenu(string savepath)
        {
            Console.WriteLine("ShoutoutReset v" + Assembly.GetExecutingAssembly().GetName().Version);

            Console.Write("Loading save... ");
            SaveData savedata = new(savepath);

            Console.WriteLine("OK\n");

            Console.WriteLine("Use the up/down arrows to make a selection, and press enter to confirm.");

            var characterSelectOptions = savedata.SaveSlots.Select(x => $"{x.HunterName} (HR {x.HunterRank})").ToList();
            var selectedCharacter      = Prompt.Select("Select a character", characterSelectOptions);

            var charIdx = characterSelectOptions.IndexOf(selectedCharacter);

            if (charIdx == -1)
            {
                Console.WriteLine("Invalid character selected!");
                return;
            }

            var saveslot = savedata.SaveSlots[charIdx];

            while (true)
            {
                Console.WriteLine();
                var action = Prompt.Select("What do you want to do?", actions);

                if (action == listAll)
                {
                    Console.WriteLine("Shoutouts:");
                    for (int i = 0; i < saveslot.Native.Shoutouts.Length; i++)
                    {
                        Console.WriteLine(ShoutoutToString(saveslot, i));
                    }
                }
                else if (action == resetSelected)
                {
                    var options = new List <string>();

                    for (int i = 0; i < saveslot.Native.Shoutouts.Length; i++)
                    {
                        options.Add(ShoutoutToString(saveslot, i));
                    }

                    var choices = Prompt.MultiSelect("Select which shoutouts you want to select.", options, pageSize: 24);

                    foreach (var choice in choices)
                    {
                        int idx = options.IndexOf(choice);
                        if (idx == -1)
                        {
                            Console.WriteLine("Invalid options: " + choice);
                        }
                        else
                        {
                            ResetShoutout(saveslot, idx);
                        }
                    }
                }
                else if (action == resetAll)
                {
                    bool confirm = Prompt.Confirm("This will rest all shoutouts to their default value. Continue?");
                    if (!confirm)
                    {
                        return;
                    }

                    for (int i = 0; i < saveslot.Native.Shoutouts.Length; i++)
                    {
                        ResetShoutout(saveslot, i);
                    }

                    Console.WriteLine("Done!");
                    Console.WriteLine("Make sure to choose 'Save and Exit' in the menu before closing this program.");
                }
                else if (action == saveAndExit)
                {
                    bool confirm = Prompt.Confirm("This will overwrite your original savedata. It is your responsibility to create a backup. Continue?");
                    if (confirm)
                    {
                        savedata.Save(savepath);
                        return;
                    }
                }
                else
                {
                    Console.WriteLine("Invalid choice!");
                }
            }
        }
Exemple #10
0
        private static void RemovePackages(RemoveOptions options)
        {
            if (getuid() != 0 && geteuid() != 0)
            {
                Console.WriteLine("It is recommended to run this tool as root!".Pastel(Color.OrangeRed));
            }

            var sip = IsSIPEnabled();

            if (sip)
            {
                options.IsForced = true;
                Console.WriteLine();
                Console.WriteLine("System Integrity Protection is enabled.".Pastel(Color.Green));
                Console.WriteLine("Critical packages bundled with macOS cannot be removed.");
                Console.WriteLine("You may remove Apple-provided packages without using 'force' flag.");
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("System Integrity Protection is disabled.".Pastel(Color.OrangeRed));
                Console.WriteLine("Critical packages bundled with macOS can now be removed.");
                Console.WriteLine("You must supply 'force' flag to remove Apple-provided packages.");
                Console.WriteLine();
            }

            try
            {
                PrefixVolume(options);
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("Volume is not mounted, or its name is invalid.".Pastel(Color.OrangeRed));
                return;
            }

            var packages = ListPackages(options.Volume);

            if (options.Packages != null && options.Packages.Any())
            {
                packages = FilterPackages(packages, options.Packages.ToArray());
            }
            else if (!string.IsNullOrEmpty(options.RegEx))
            {
                try
                {
                    var regex = new Regex(options.RegEx);
                    packages = FilterPackages(packages, regex);
                }
                catch (ArgumentException)
                {
                    Console.WriteLine("RegEx is invalid.".Pastel(Color.OrangeRed));
                    return;
                }
            }
            else
            {
                Console.WriteLine(
                    "You must supply at least one package ID, or a single regex.".Pastel(Color.OrangeRed));
                return;
            }

            if (packages.Length == 0)
            {
                Console.WriteLine("No packages found matching given conditions.".Pastel(Color.Orange));
                return;
            }

            Console.WriteLine();
            Console.WriteLine(string.Join(Environment.NewLine, packages));
            Console.WriteLine($"{packages.Length} package(s) will be removed.".Pastel(Color.Orange));
            Console.WriteLine();

            var shouldContinue = options.QuietRemoval || Prompt.Confirm("Continue?", true);

            if (!shouldContinue)
            {
                Console.WriteLine("User cancelled removal operation.");
                return;
            }

            foreach (var package in packages)
            {
                if (RemovePackage(package, options.IsForced, options.QuietRemoval))
                {
                    Console.WriteLine($"Package '{package}' was removed!".Pastel(Color.Green));
                }
                else
                {
                    Console.WriteLine($"Package '{package}' was not removed!".Pastel(Color.OrangeRed));
                }
            }
        }
Exemple #11
0
        private static bool RemovePackage(string id, bool forced, bool quietly)
        {
            if (id.StartsWith("com.apple.pkg.", StringComparison.OrdinalIgnoreCase) &&
                !forced)
            {
                Console.WriteLine();
                Console.WriteLine("This package was added by Apple or macOS installer.");
                Console.WriteLine("With SIP disabled, you must remove it with 'force' flag.".Pastel(Color.OrangeRed));
                return(false);
            }

            Console.WriteLine();
            Console.WriteLine($"Removing package '{id}'...");

            var(files, folders) = InspectPackage(id);
            if (files.Length > 0)
            {
                Console.WriteLine();
                Console.WriteLine(string.Join(Environment.NewLine, files));
                Console.WriteLine($"{files.Length} file(s) will be permanently deleted!".Pastel(Color.OrangeRed));
                Console.WriteLine();

                var shouldContinue = quietly || Prompt.Confirm("Continue?");
                if (!shouldContinue)
                {
                    return(false);
                }

                try
                {
                    RemoveFiles(id, files);
                }
                catch (UnauthorizedAccessException)
                {
                    Console.WriteLine();
                    Console.WriteLine("You must be root to remove this package!".Pastel(Color.OrangeRed));
                    return(false);
                }
            }

            if (folders.Length > 0)
            {
                Console.WriteLine();
                Console.WriteLine(string.Join(Environment.NewLine, folders));
                Console.WriteLine(
                    $"{folders.Length} folder(s) will be permanently deleted when empty!".Pastel(Color.OrangeRed));
                Console.WriteLine();

                var shouldContinue = quietly || Prompt.Confirm("Continue?");
                if (!shouldContinue)
                {
                    return(false);
                }

                try
                {
                    RemoveDirectories(folders);
                }
                catch (UnauthorizedAccessException)
                {
                    Console.WriteLine();
                    Console.WriteLine("You must be root to remove this package!".Pastel(Color.OrangeRed));
                    return(false);
                }
            }

            RemoveReceipt(id);

            return(true);
        }
Exemple #12
0
        public void Run()
        {
            Console.Clear();
            Header("biblioZ-cli", "Interface de linea de comando para BiblioZone");

            try
            {
                int opcion = Prompt.Menu("Seleccionar una de las acciones que queres realizar", new[]
                {
                    "Importar Libros desde --file y ejecutar las pruebas en memoria",
                    "Importar Libros desde --file y guardar en la DB",
                    "*** Importar Autores desde --file [falta implementar guardar en la DB]",
                    "Consultas varias desde el contexto",
                    "Pruebas ingresando Libros"
                });

                //  TODO_HECHO obtener archivo desde la configuracion
                //
                //  --file=D:\CURSOS\INCOMPANY\clase\datos\libros.csv --tipo=libros
                //
                //  --file=D:\CURSOS\INCOMPANY\clase\datos\autores.csv --tipo=autores
                //
                //  NOTA: cuando ponemos el menu, no tiene sentido usar la opcion --tipo
                //
                string file = _config["file"];

                if (opcion.In(0, 2, 1) && file == null)
                {
                    throw new ApplicationException("La opcion seleccionada necesita que se pase un archivo en --file");
                }

                switch (opcion)
                {
                case 0:
                {
                    if (Prompt.Confirm($"Es el archivo correcto? ==> {file}"))
                    {
                        _logger.LogInformation("Iniciando el procesamiento del archivo de Libros {archivo}", file);

                        IEnumerable <Libro> lista = _imp.ImportarCSV(file);

                        _logger.LogInformation("Ejecutando pruebas en memoria...");

                        //  ejecutamos las pruebas sobre la lista importada (memoria)
                        //
                        Pruebas(lista);
                    }
                }
                break;

                case 1:
                {
                    if (Prompt.Confirm($"Es el archivo correcto? ==> {file}"))
                    {
                        _logger.LogInformation("Iniciando el procesamiento del archivo de Libros {archivo}", file);

                        IEnumerable <Libro> lista = _imp.ImportarCSV(file);

                        _logger.LogInformation("Iniciando el proceso de exportacion");

                        //  eliminamos los datos previos??
                        if (Prompt.Confirm("Eliminamos datos previos?", true,
                                           "WARNING Esta operacion eliminara todos los datos de las 3 tablas de Articulos!!"))
                        {
                            _exp.ClearDatabase();
                        }

                        //  pasamos la responsabilidad de la exportacion al componente adecuado...
                        //
                        _exp.ExportarListaDeLibros(lista);
                    }
                }
                break;

                case 2:
                {
                    if (Prompt.Confirm($"Es el archivo correcto? ==> {file}"))
                    {
                        _logger.LogInformation("Iniciando el procesamiento del archivo de Autores {archivo}", file);

                        var autoresTemp = _imp.ImportarAutores(file);

                        Console.WriteLine("Lista de autores importados...");

                        foreach (var item in autoresTemp)
                        {
                            Console.WriteLine($"Se importo el siguiente par (idLibro, autor) ==> {item}");

                            _logger.LogDebug("Se importo el siguiente par (idLibro, autor) ==> {tupla}", item);
                        }
                    }
                }
                break;

                case 3:
                {
                    string editorial = Prompt.Input <string>("Ingresar el nombre de una editorial");

                    Console.WriteLine($"Titulos para la Editorial {editorial}:\n");

                    foreach (string titulo in _exp.ObtenerTitulosDeEditorial(editorial))
                    {
                        Console.WriteLine(titulo);
                    }
                }
                break;

                case 4:
                {
                    Console.WriteLine($"Pruebas de ingresos varias para libros y autores:\n");
                    string titulo = Prompt.Input <string>("Ingresar titulo o parte del titulo");

                    var libroResultado = _exp.GetLibros(titulo).FirstOrDefault();

                    if (libroResultado == null)
                    {
                        //  crear nuevo libro...
                        libroResultado = new Libro()
                        {
                            ID          = "1234",
                            Titulo      = titulo,
                            Publicacion = null
                        };
                    }
                    else
                    {
                        Console.WriteLine($"Autores del libro: {libroResultado.Titulo}");

                        foreach (var au in libroResultado.LibroAutores)
                        {
                            Console.WriteLine($"ID={au.ID_Autor} ; Nombre={au.Autor.Nombre}");
                        }
                    }

                    string autor          = Prompt.Input <string>("Ingresar nombre del autor (exacto)");
                    var    autorResultado = _exp.GetAutor(autor);

                    if (autorResultado == null)
                    {
                        autorResultado = new Autor()
                        {
                            Nombre = autor
                        };
                    }
                    else
                    {
                        Console.WriteLine($"Libros escritos por {autor}");

                        foreach (var li in autorResultado.AutorLibros)
                        {
                            Console.WriteLine($"{li.Libro.Titulo}");
                        }
                    }

                    //  PARA MEDITAR -- De que manera podemos evitar el UPDATE del Libro que no esta modificado??
                    //
                    libroResultado.LibroAutores.Add(new LibroAutor()
                        {
                            Libro = libroResultado, Autor = autorResultado
                        });

                    _exp.AgregarLibro(libroResultado);
                    //  _exp.AgregarLibroAutor(new LibroAutor() { Libro = libroResultado, Autor = autorResultado });

                    Console.WriteLine($"GUID: {libroResultado.ID_Real} Fecha: {libroResultado.Publicacion}");
                }
                break;
                }
            }
            catch (ApplicationException ex) when(ex.Data.Contains("archivo"))
            {
                Console.WriteLine($"Se produjo una excepcion {ex.Message} Archivo: {ex.Data["archivo"]}");
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                Console.WriteLine();
                Console.WriteLine("[finally] ==> programa terminado!!");
            }
        }
Exemple #13
0
        public bool Confirm(string prompt, bool?defaultValue = null)
        {
            var confirm = Prompt.Confirm(prompt, defaultValue);

            return(confirm);
        }
Exemple #14
0
        public override async Task <int> ExecuteAsync(CommandContext context, Settings settings)
        {
            var paths      = new List <string>();
            var di         = new DirectoryInfo(settings.FolderPath);
            var toContinue = Prompt.Confirm("Looks like this directory is empty. Would you like to initialise it for packing?", true);

            if (!toContinue)
            {
                return(-1);
            }
            else
            {
                var objs       = new List <VehicleSlot>();
                var categories = Prompt.MultiSelect("Please select the file types you will be packing", new[] { "Player Aircraft", "Non-playable Aircraft", "Vessels" });
                // var cat
                if (categories.Contains("Player Aircraft"))
                {
                    var aircraft = Prompt.MultiSelect("Please select the aircraft you want to set up", Constants.PlayerAircraft, valueSelector: n => n.Name);
                    var useNpc   = false;
                    if (aircraft.Any(a => a.NPCSlots.Any()))
                    {
                        useNpc = Prompt.Confirm("Would you like to create folders for the NPC variants?");
                    }
                    objs.AddRange(aircraft);
                }
                if (categories.Contains("Non-playable Aircraft"))
                {
                    var npAircraft = Prompt.MultiSelect("Please select the non-playable aircraft you want to set up", Constants.NonPlayableAircraft, valueSelector: n => n.Name);
                    objs.AddRange(npAircraft);
                }
                if (categories.Contains("Vessels"))
                {
                    var vesselChoice = Prompt.MultiSelect("Please select the vessels you want to set up", Constants.Vessels, valueSelector: n => n.Name);
                    objs.AddRange(vesselChoice);
                }
                foreach (var obj in objs)
                {
                    var objPath    = obj.PathRoot + obj.ObjectName;
                    var targetPath = Path.Combine(di.Name == "Nimbus" ? Directory.GetParent(di.FullName).FullName : di.FullName, objPath);
                    _logger.LogInformation($"Created object structure for {obj.Name}/{obj.ObjectName}");
                    Directory.CreateDirectory(targetPath);
                    if (obj is AircraftSlot ac)
                    {
                        Directory.CreateDirectory(Path.Combine(targetPath, "Materials"));
                        if (ac.Factions.HasValue)
                        {
                            if (ac.HasFaction(NPCFaction.Universal))
                            {
                                Directory.CreateDirectory(Path.Combine(targetPath, "Textures"));
                            }
                            if (ac.HasFaction(NPCFaction.Osea))
                            {
                                Directory.CreateDirectory(Path.Combine(targetPath, "00"));
                            }
                            if (ac.HasFaction(NPCFaction.Erusea))
                            {
                                Directory.CreateDirectory(Path.Combine(targetPath, "01"));
                            }
                        }
                        else
                        {
                            foreach (var regSlot in Enumerable.Range(0, 8))
                            {
                                Directory.CreateDirectory(Path.Combine(targetPath, $"0{regSlot}"));
                            }
                        }
                        foreach (var npcSlot in ac.NPCSlots)
                        {
                            Directory.CreateDirectory(Path.Combine(targetPath, npcSlot));
                        }
                    }
                    if (obj is VesselSlot vs)
                    {
                        Directory.CreateDirectory(Path.Combine(targetPath, "Materials"));
                        Directory.CreateDirectory(Path.Combine(targetPath, "Textures"));
                    }
                }
                _logger.LogWarning("Slot-specific folders have been created for all playable aircraft for slots 1-8");
                _logger.LogWarning("You should check exactly which slots your chosen aircraft actually suppports before packing!");
                _logger.LogInformation($"Object folders have been set up for {objs.Count} objects!");
                AnsiConsole.WriteLine("Press <ENTER> to continue...");
                System.Console.ReadLine();
            }
            return(0);
        }
Exemple #15
0
 public static bool OverwriteFileName(string fileName)
 {
     return(fileName == Shipwreck.CurrentGame.SaveFileName ||
            Prompt.Confirm($"{fileName} already exists. Would you like to overwrite it?", true));
 }