コード例 #1
0
ファイル: Love2dBoot.cs プロジェクト: endlesstravel/Love2dCS
        static public void Init(BootConfig bootConfig = null)
        {
            if (InitFlag == false)
            {
                InitFlag = true;

                // output the version
                var versionInfo = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                Log.Info($"[Version: {versionInfo}]");

                // config
                if (bootConfig == null)
                {
                    bootConfig = new BootConfig();
                }

                // init to load native library
                try
                {
                    InitNativeLibrary();
                    Love2dDll.LoadInit();
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    throw e;
                }

                if (bootConfig.DefaultRandomSeed.HasValue)
                {
                    Mathf.Init(bootConfig.DefaultRandomSeed.Value);
                }
                else
                {
                    Mathf.Init();
                }

                FileSystem.Init("");

                Timer.Init();
                Event.Init();
                Keyboard.Init();
                Joystick.Init();
                Mouse.Init();
                Touch.Init();
                Sound.Init();

                Audio.Init();
                Font.Init();
                Image.Init();
                Video.Init();
                Window.Init();
                Graphics.Init();
                Special.Init();

                if (bootConfig.WindowTitle != null)
                {
                    Window.SetTitle(bootConfig.WindowTitle);
                }

                WindowSettings settings = new WindowSettings();
                settings.FullscreenType = bootConfig.WindowFullscreenType;
                settings.Fullscreen     = bootConfig.WindowFullscreen;
                settings.Vsync          = bootConfig.WindowVsync;
                settings.MSAA           = bootConfig.WindowMSAA;
                settings.Resizable      = bootConfig.WindowResizable;
                settings.MinWidth       = bootConfig.WindowMinWidth;
                settings.MinHeight      = bootConfig.WindowMinHeight;
                settings.Borderless     = bootConfig.WindowBorderless;
                settings.Centered       = bootConfig.WindowCentered;
                settings.Display        = bootConfig.WindowDisplay;
                settings.HighDpi        = bootConfig.WindowHighdpi;
                if (bootConfig.WindowX.HasValue)
                {
                    settings.X = bootConfig.WindowX.Value;
                }
                if (bootConfig.WindowY.HasValue)
                {
                    settings.Y = bootConfig.WindowY.Value;
                }
                Window.SetMode(bootConfig.WindowWidth, bootConfig.WindowHeight, settings);

                FileSystem.SetSource(Environment.CurrentDirectory);

                Log.Info($"FileSystem current work directory : {FileSystem.GetSource()}");
            }
        }