Esempio n. 1
0
        private void InitGameEngine()
        {
            // 初始化引擎
            gameEngine = new GameEngine();
            gameEngine.InitCore();

            //-- create engine config
            CustomConfigurationSection configuration = CustomConfigurationSection.Open();

            GameWindow.ClientSize = new Size(configuration.EngineSetting.ClientWidth, configuration.EngineSetting.ClientHeight);
            NEngineConfig engineCfg = new NEngineConfig();

            engineCfg.RenderWndHandle    = GameWindow.RenderHandle;
            engineCfg.ClientWidth        = Screen.PrimaryScreen.Bounds.Width;
            engineCfg.ClientHeight       = Screen.PrimaryScreen.Bounds.Height;
            engineCfg.ColorBits          = configuration.EngineSetting.ColorBits;
            engineCfg.FullScreen         = configuration.EngineSetting.FullScreen;
            engineCfg.EnableHDR          = configuration.EngineSetting.EnableHDR;
            engineCfg.EnableSSAO         = configuration.EngineSetting.EnableSSAO;
            engineCfg.RenderClass        = configuration.EngineSetting.RenderClass;
            engineCfg.FileSystemClass    = configuration.EngineSetting.FileSystemClass;
            engineCfg.EngineDataPkg      = configuration.EngineSetting.EngineDataPkg;
            engineCfg.ResourceCacheClass = configuration.EngineSetting.ResourceCacheClass;
            engineCfg.ResourceIOClass    = configuration.EngineSetting.ResourceIOClass;
            engineCfg.FileSystemRoot     = configuration.EngineSetting.FileSystemRoot;
            if (string.IsNullOrEmpty(engineCfg.FileSystemRoot))
            {
                engineCfg.FileSystemRoot = NFileSystem.DefaultFileSystemRoot;
            }

            configuration.Save();

            //初始化引擎
            gameEngine.InitModules(engineCfg);

            //-- create editor windows
            GameWindow.ViewportControl.CreateViewport();
        }
Esempio n. 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // 创建log
            NLogger.Instance.AddLogOutput(new NFileLogOutput("NexusEditor.log"));

            // 读取本地化配置
            NexusEditor.Properties.Resources.Culture = new CultureInfo(ConfigurationManager.AppSettings["Localization"]);

            SplashForm.StartSplash(NexusEditor.Properties.Resources.EditorSplash);

            try
            {
                engine = new NLevelEditorEngine();
                engine.InitCore();

                mainForm = new EditorMainForm();
                mainForm.CreateLogForm();

                //-- create engine config
                CustomConfigurationSection configuration = CustomConfigurationSection.Open();
                mainForm.ClientSize = new Size(configuration.EngineSetting.ClientWidth, configuration.EngineSetting.ClientHeight);
                NEngineConfig engineCfg = new NEngineConfig();
                engineCfg.RenderWndHandle    = mainForm.RenderPanelHandle;
                engineCfg.ClientWidth        = Screen.PrimaryScreen.Bounds.Width;
                engineCfg.ClientHeight       = Screen.PrimaryScreen.Bounds.Height;
                engineCfg.ColorBits          = configuration.EngineSetting.ColorBits;
                engineCfg.FullScreen         = configuration.EngineSetting.FullScreen;
                engineCfg.EnableHDR          = configuration.EngineSetting.EnableHDR;
                engineCfg.EnableSSAO         = configuration.EngineSetting.EnableSSAO;
                engineCfg.RenderClass        = configuration.EngineSetting.RenderClass;
                engineCfg.FileSystemClass    = configuration.EngineSetting.FileSystemClass;
                engineCfg.EngineDataPkg      = configuration.EngineSetting.EngineDataPkg;
                engineCfg.ResourceCacheClass = configuration.EngineSetting.ResourceCacheClass;
                engineCfg.ResourceIOClass    = configuration.EngineSetting.ResourceIOClass;
                engineCfg.FileSystemRoot     = configuration.EngineSetting.FileSystemRoot;
                if (string.IsNullOrEmpty(engineCfg.FileSystemRoot))
                {
                    engineCfg.FileSystemRoot = NFileSystem.DefaultFileSystemRoot;
                }

                //--
                NEditorConfig editorCfg = new NEditorConfig();
                editorCfg.actorEdClassAssembly = configuration.EditorEngineSetting.ActorEdClassAssembly;
                editorCfg.actorEditorClass     = configuration.EditorEngineSetting.ActorEditorClass;

                configuration.Save();

                engine.InitModules(engineCfg, editorCfg);
            }
            catch (System.Exception e)
            {
                ShowException(e, "Nexus Engine Init FAILED!");
                engine.Dispose();
                mainForm.Dispose();
                return;
            }

            try
            {
                //-- create default level
                engine.CreateMainLevel("defaultLevel");

                //-- create editor windows
                mainForm.CreateEditorForms();
                mainForm.CreateViewport();

                //-- open resrouce
                resourceForm = new ResourceEditorForm();

                SplashForm.CloseSplash();

                //-- run
                resourceForm.Show();
                mainForm.Show();
                mainForm.BringToFront();
                Application.Run(mainForm);
            }
            catch (System.Exception e)
            {
                ShowException(e, "Nexus Engine Exception!");
            }
            //-- close
            resourceForm.Close();
            engine.Close();
            engine.Dispose();

            NLogger.Instance.Clear();

            mainForm.Dispose();
        }