public StoryboardWindow(int width = 640, int height = 480) :
            //opentk >= 4.0.0 NOT WORK
            base(new GameWindowSettings
        {
            IsMultiThreaded = false
        }, new NativeWindowSettings
        {
            API        = ContextAPI.OpenGL,
            APIVersion = new Version(3, 3),
            Flags      = ContextFlags.ForwardCompatible,
            Profile    = ContextProfile.Core,
            Title      = "Esu!StoryboardPlayer",
            Size       = new Vector2i(width, height)
        })
            //opentk < 4.0.0 WORK

            /*base(width, height, new GraphicsMode(ColorFormat.Empty, 32), "Esu!StoryboardPlayer"
             * , GameWindowFlags.FixedWindow, DisplayDevice.Default, 3, 3, GraphicsContextFlags.ForwardCompatible)*/
        {
            //VSync = VSyncMode.Off;
            CurrentWindow = this;
            RenderKernel.Init();

            ApplyBorderless(PlayerSetting.EnableBorderless);
            SwitchFullscreen(PlayerSetting.EnableFullScreen);
        }
예제 #2
0
        public static void Main(string[] argv)
        {
            //Test();
            Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory;

            //hook Ctrl-C action for console window.
            SetConsoleCtrlHandler(type => {
                Exit();
                return(true);
            }, false);

            //apply settings from file
            PlayerSetting.Init();

            //apply settings from commandline
            var args = ParseProgramCommands(argv, out var beatmap_folder);

            //apply features and settings from diff envs
            EnvironmentHelper.SetupEnvironment();

            //Update check and notify
            if (PlayerSetting.EnableUpdateCheck)
            {
                ProgramUpdater.UpdateCheck();
            }

            //clean temp folder if updated just now.
            ProgramUpdater.CleanTemp();

            PlayerSetting.PrintSettings();

            //init window
            StoryboardWindow window = new StoryboardWindow(PlayerSetting.Width, PlayerSetting.Height);

            Log.User($"Start to parse folder :{beatmap_folder}");

            if (Directory.Exists(beatmap_folder))
            {
                var info     = BeatmapFolderInfoEx.Parse(beatmap_folder, args);
                var instance = StoryboardInstance.Load(info);

                window.LoadStoryboardInstance(instance);

                var player = new MusicPlayer();
                player.Load(info.audio_file_path);
                MusicPlayerManager.ApplyPlayer(player);

                var auto_trigger = ToolManager.GetOrCreateTool <AutoTrigger>();
                auto_trigger.Load(info);
                auto_trigger.Trim();
            }
            else
            {
                Exit($"You have to select a beatmap folder which contains storyboard to play");
            }

            if (PlayerSetting.EncodingEnvironment)
            {
                //init encoding environment
                var                   encoding_opt    = new EncoderOption(args);
                EncodingKernel        encoding_kernel = new EncodingKernel(encoding_opt);
                EncodingProcessPlayer encoding_player = new EncodingProcessPlayer(MusicPlayerManager.ActivityPlayer.Length, encoding_opt.FPS);
                MusicPlayerManager.ActivityPlayer.Pause();
                MusicPlayerManager.ApplyPlayer(encoding_player);
                ToolManager.AddTool(encoding_kernel);
                encoding_kernel.Start();
            }

            #region Setup Loop Playback

            if ((PlayerSetting._LoopPlayStartTime != null || PlayerSetting._LoopPlayEndTime != null) && MusicPlayerManager.ActivityPlayer is MusicPlayer mp)
            {
                var len = mp.Length;

                LoopPlayer lp = new LoopPlayer(PlayerSetting._LoopPlayStartTime ?? 0, PlayerSetting._LoopPlayEndTime ?? len);

                Log.User($"Loop playback : {lp}");

                MusicPlayerManager.ApplyPlayer(lp);
            }

            #endregion

            MusicPlayerManager.ActivityPlayer.Volume = PlayerSetting.Volume;

            MusicPlayerManager.ActivityPlayer?.Play();

            window.Run();

            /*/ 不曾设想的操作.jpg
             * window.IsVisible = true;
             * window.RefreshResize();
             *
             * while (true)
             * {
             *  UpdateKernel.Update();
             *  RenderKernel.Draw();
             *  window.SwapBuffers();
             *  UpdateKernel.FrameRateLimit();
             *  Application.DoEvents();
             * }
             * /*/
        }