예제 #1
0
        private async Task Generate_Impl()
        {
            var fogOptions = new FogGenerationOptions
            {
                ShouldGenerate            = ShouldGenerateFog,
                ChangeFogColorEveryNthBar = Preferences.FogChangeBars,
                RandomizeColors           = Preferences.FogRandomize,
                MinTimeBetweenNotes       = (float)Preferences.FogMinTime,
                GenerationMethod          = Preferences.FogMethod,
                SelectedSingleFogColor    = (byte)SelectedSingleFogColor,
            };

            var beamOptions = new BeamGenerationOptions
            {
                ShouldGenerate      = ShouldGenerateBeams,
                GenerationMethod    = Preferences.BeamMethod,
                MinTimeBetweenNotes = (float)Preferences.BeamMinTime,
                RandomizeColors     = Preferences.BeamRandomize,
                UseCompatibleColors = Preferences.BeamCompatibleColors
            };

            var laserOptions = new LaserGenerationOptions
            {
                ShouldGenerate     = ShouldGenerateLasers,
                DisableLaserLights = Preferences.DisableLasers
            };

            var generator = new Generator(ArrangementForFogFilename, ArrangementForBeamsFilename, fogOptions, beamOptions, laserOptions);

            try
            {
                ShowlightsList = await Task.Run(() => generator.Generate(CurrentShowlights.Select(x => x.Model))).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                services.ShowError(
                    "Generation failed: " + Environment.NewLine +
                    ex.Message + Environment.NewLine +
                    Environment.NewLine +
                    ex.StackTrace
                    );
            }

            Hide(result: true);
        }
예제 #2
0
        private static int Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            int returnCode = 0;

            Parser.Default
            .ParseArguments <Options>(args)
            .WithParsed(o =>
            {
                var beamSourceArrangement = o.BeamSourceArrangement switch
                {
                    null => o.FogSourceArrangement,
                    _ => o.BeamSourceArrangement
                };

                var targetPath = o.TargetPath switch
                {
                    null => Path.Combine(".", "showlights.xml"),
                    _ => o.TargetPath
                };

                var fogOptions = new FogGenerationOptions
                {
                    ShouldGenerate            = true,
                    GenerationMethod          = ParseFogMethod(o.FogMethod),
                    MinTimeBetweenNotes       = Math.Max(0.01f, o.FogTime),
                    ChangeFogColorEveryNthBar = Math.Max(1, o.FogBars),
                    RandomizeColors           = o.Randomize.Contains("fog")
                };

                var beamOptions = new BeamGenerationOptions
                {
                    ShouldGenerate      = true,
                    GenerationMethod    = ParseBeamMethod(o.BeamMethod),
                    MinTimeBetweenNotes = Math.Max(0.01f, o.BeamTime),
                    UseCompatibleColors = o.UseCompatibleColors,
                    RandomizeColors     = o.Randomize.Contains("beam")
                };

                var laserOptions = new LaserGenerationOptions
                {
                    ShouldGenerate     = true,
                    DisableLaserLights = o.EnableLasers != true
                };

                if (o.Verbose)
                {
                    Console.WriteLine("FOG");
                    Console.WriteLine("Source: {0}", o.FogSourceArrangement);
                    Console.WriteLine("Method: {0}", fogOptions.GenerationMethod);
                    if (fogOptions.GenerationMethod == FogGenerationMethod.ChangeEveryNthBar)
                    {
                        Console.WriteLine("Minimum bars: {0}", fogOptions.ChangeFogColorEveryNthBar);
                    }
                    else if (fogOptions.GenerationMethod == FogGenerationMethod.MinTimeBetweenChanges)
                    {
                        Console.WriteLine("Minimum time: {0} seconds", fogOptions.MinTimeBetweenNotes);
                    }
                    Console.WriteLine("Randomized: {0}", fogOptions.RandomizeColors);

                    Console.WriteLine("--------------------------------------------");

                    Console.WriteLine("BEAMS");
                    Console.WriteLine("Source: {0}", beamSourceArrangement);
                    Console.WriteLine("Method: {0}", beamOptions.GenerationMethod);
                    if (beamOptions.GenerationMethod == BeamGenerationMethod.MinTimeBetweenChanges)
                    {
                        Console.WriteLine("Minimum time: {0} seconds", beamOptions.MinTimeBetweenNotes);
                    }
                    Console.WriteLine("Use compatible colors: {0}", beamOptions.UseCompatibleColors);
                    Console.WriteLine("Randomized: {0}", beamOptions.RandomizeColors);

                    Console.WriteLine("--------------------------------------------");

                    Console.WriteLine("LASERS");
                    Console.WriteLine("Enabled: {0}", !laserOptions.DisableLaserLights);

                    Console.WriteLine("--------------------------------------------");

                    Console.WriteLine("Output path: {0}", targetPath);
                }

                try
                {
                    var generator = new Generator(o.FogSourceArrangement, beamSourceArrangement, fogOptions, beamOptions, laserOptions);

                    ShowLights.Save(targetPath, generator.Generate());

                    if (o.Verbose)
                    {
                        Console.WriteLine("File generated successfully.");
                    }
                } catch (Exception e)
                {
                    Console.WriteLine("ERROR: Generation failed: {0}", e.Message);
                    Console.WriteLine(e.StackTrace);
                    returnCode = 1;
                }
            });

            return(returnCode);
        }