Exemple #1
0
        public static void WebPlayer_Message(EngineApp.WebPlayerMessages message, IntPtr data)
        {
            try
            {
                switch (message)
                {
                case EngineApp.WebPlayerMessages.Init:

                    unsafe
                    {
                        EngineApp.WebPlayerInitData *initData = (EngineApp.WebPlayerInitData *)data;

                        if (!VirtualFileSystem.Init("user:Logs/WebPlayer.log", false,
                                                    initData->ExecutableDirectoryPath, null, null))
                        {
                            return;
                        }
                        Log.DumpToFile(string.Format("WebPlayer {0}\r\n",
                                                     EngineVersionInformation.Version));

                        //set render settings
                        //RendererWorld.InitializationOptions.MaxPixelShadersVersion = RendererWorld.MaxPixelShadersVersions.PS0;
                        //RendererWorld.InitializationOptions.MaxVertexShadersVersion = RendererWorld.MaxVertexShadersVersions.VS0;
                        //RendererWorld.InitializationOptions.FullSceneAntialiasing = 0;
                        //RendererWorld.InitializationOptions.FilteringMode = RendererWorld.FilteringModes.Trilinear;

                        EngineApp.Init(new GameEngineApp());

                        EngineApp.WebPlayer_Message(message, data);

                        EngineConsole.Init();

                        EngineApp.Instance.Config.RegisterClassParameters(typeof(GameEngineApp));

                        EngineApp.Instance.Create();
                    }
                    break;

                case EngineApp.WebPlayerMessages.Shutdown:

                    EngineApp.WebPlayer_Message(message, data);

                    EngineApp.Shutdown();
                    Log.DumpToFile("Program END\r\n");
                    VirtualFileSystem.Shutdown();

                    break;

                case EngineApp.WebPlayerMessages.WindowMessage:
                    EngineApp.WebPlayer_Message(message, data);
                    break;
                }
            }
            catch (Exception e)
            {
                Log.FatalAsException(e.ToString());
            }
        }
Exemple #2
0
        static void Main2()
        {
            //set application type
            EngineApp.ApplicationType = EngineApp.ApplicationTypeEnum.Simulation;

            //initialize file system of the engine
            ProjectUtility.GetDefaultProjectPaths(out string projectDirectory, out string userSettingsDirectory);
            if (!VirtualFileSystem.Init("user:Logs/Player.log", true, projectDirectory, userSettingsDirectory))
            {
                return;
            }

            //configure general settings
            EngineApp.InitSettings.ConfigVirtualFileName = "user:Configs/Player.config";

            EngineApp.InitSettings.AllowChangeScreenVideoMode = true;

            //these parameters are enabled by default
            //EngineApp.EnginePauseWhenApplicationIsNotActive = false;
            //EngineApp.InitSettings.UseDirectInputForMouseRelativeMode = false;
            //EngineApp.InitSettings.AllowJoysticksAndSpecialInputDevices = false;

            //Change Floating Point Model for FPU math calculations. Default is Strict53Bits.
            //SystemSettings.FloatingPointModel = SystemSettings.FloatingPointModelEnum.Strict53Bits;

            //init engine application
            EngineApp.Init();

            EngineApp.InitSettings.CreateWindowState = EngineApp.WindowStateEnum.Maximized;
            //EngineApp.InitSettings.CreateWindowState = EngineApp.WindowStateEnum.Normal;
            //var screenSize = EngineApp.GetScreenSize().ToVec2();
            //EngineApp.InitSettings.CreateWindowSize = new Vec2( screenSize.X * 0.85, screenSize.Y * 0.9 ).ToVec2I();

            //create and run application loop.
            if (EngineApp.Create())
            {
                if (SystemSettings.CurrentPlatform == SystemSettings.Platform.Windows || SystemSettings.CurrentPlatform == SystemSettings.Platform.UWP)
                {
                    EngineApp.CreatedInsideEngineWindow.Icon = NeoAxis.Player.Properties.Resources.Logo;
                }

                EngineApp.Run();
            }

            EngineApp.Shutdown();

            Log.DumpToFile("Program END\r\n");

            VirtualFileSystem.Shutdown();

            if (needRestartApplication)
            {
                Process.Start(Assembly.GetExecutingAssembly().Location, "");
            }
        }
        static void Main2()
        {
            //initialize file sytem of the engine
            if (!VirtualFileSystem.Init("user:Logs/Game.log", true, null, null, null, null))
            {
                return;
            }

            //configure general settings
            EngineApp.ConfigName = "user:Configs/Game.config";
            if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows)
            {
                EngineApp.UseDirectInputForMouseRelativeMode = true;
            }
            EngineApp.AllowJoysticksAndCustomInputDevices = true;
            EngineApp.AllowWriteEngineConfigFile          = true;
            EngineApp.AllowChangeVideoMode = true;
            //Change Floating Point Model for FPU math calculations. Default is Strict53Bits.
            //FloatingPointModel.Model = FloatingPointModel.Models.Strict53Bits;

            //init engine application
            EngineApp.Init(new GameEngineApp());
            //enable support field and properties serialization for GameEngineApp class.
            EngineApp.Instance.Config.RegisterClassParameters(typeof(GameEngineApp));

            //update window
            EngineApp.Instance.WindowTitle = "Game";
            if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows)
            {
                EngineApp.Instance.Icon = Game.Properties.Resources.Logo;
            }

            //create game console
            EngineConsole.Init();

            //EngineApp.Instance.SuspendWorkingWhenApplicationIsNotActive = false;

            //create and run application loop.
            if (EngineApp.Instance.Create())
            {
                EngineApp.Instance.Run();
            }

            EngineApp.Shutdown();

            Log.DumpToFile("Program END\r\n");

            VirtualFileSystem.Shutdown();

            if (needRestartApplication)
            {
                Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location, "");
            }
        }
Exemple #4
0
        public static void Shutdown()
        {
            while (renderTargetUserControls.Count != 0)
            {
                renderTargetUserControls[0].Destroy();
            }

            EngineApp.Instance.Destroy();
            EngineApp.Shutdown();
            Log.DumpToFile("Program END\r\n");
            VirtualFileSystem.Shutdown();
        }
Exemple #5
0
        static void Main2()
        {
            if (!VirtualFileSystem.Init("user:Logs/Game.log", true, null, Directory.GetCurrentDirectory() + "\\..\\Data",
                                        Directory.GetCurrentDirectory() + "\\..\\UserSettings"))
            {
                return;
            }

            EngineApp.ConfigName = "user:Configs/Game.config";

            if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows)
            {
                EngineApp.UseDirectInputForMouseRelativeMode = true;
            }
            EngineApp.AllowJoysticksAndCustomInputDevices = true;
            EngineApp.AllowWriteEngineConfigFile          = true;
            EngineApp.AllowChangeVideoMode = true;

            // enable vsync. should no have verticalSync option in the Engine.config
            //RendererWorld.InitializationOptions.VerticalSync = true;

            //Change Floating Point Model for FPU math calculations. Default is Strict53Bits.
            //FloatingPointModel.Model = FloatingPointModel.Models.Strict53Bits;

            EngineApp.Init(new GameEngineApp());
            EngineApp.Instance.WindowTitle = "AOT";

            if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows)
            {
                EngineApp.Instance.Icon = AOT.Properties.Resources.Logo;
            }

            EngineConsole.Init();

            EngineApp.Instance.Config.RegisterClassParameters(typeof(GameEngineApp));

            //EngineApp.Instance.SuspendWorkingWhenApplicationIsNotActive = false;

            if (EngineApp.Instance.Create())
            {
                EngineApp.Instance.Run();
            }

            EngineApp.Shutdown();

            Log.DumpToFile("Program END\r\n");

            VirtualFileSystem.Shutdown();
        }
Exemple #6
0
        public static void Shutdown()
        {
            while (renderTargetUserControls.Count != 0)
            {
                renderTargetUserControls[0].Destroy();
            }

            EngineApp.Instance.Destroy();
            EngineApp.Shutdown();
            Log.DumpToFile("Program END\r\n");
            VirtualFileSystem.Shutdown();

            //bug fix for ".NET-BroadcastEventWindow" error
            Application.Exit();
        }
Exemple #7
0
        protected override void OnDestroy()
        {
            if (EditorUtility.IsDesignerHosted(this))
            {
                return;
            }

            if (MainWidget)
            {
                if (!canSaveConfig)
                {
                    EngineApp.NeedSaveConfig = false;
                }
                EngineApp.Shutdown();
            }

            base.OnDestroy();
        }
Exemple #8
0
        public static void WPFShutdown()
        {
            try
            {
                foreach (var control in WidgetControlWPF.AllInstances.ToArray())
                {
                    if (control.InnerControl != null && !control.InnerControl.Destroyed)
                    {
                        control.InnerControl.AllowCreateRenderWindow = false;
                        control.InnerControl.DestroyRenderTarget();
                    }
                }
            }
            catch { }

            EngineApp.Shutdown();
            Log.DumpToFile("Program END\r\n");
            VirtualFileSystem.Shutdown();

            ////bug fix for ".NET-BroadcastEventWindow" error
            //Application.Exit();
        }
Exemple #9
0
        static void Main2()
        {
            if (!VirtualFileSystem.Init("user:Logs/Game.log", true, null, null, null))
            {
                return;
            }
            Log.DumpToFile(string.Format("Game {0}\r\n", EngineVersionInformation.Version));

            EngineApp.ConfigName = "user:Configs/Game.config";
            EngineApp.UseSystemMouseDeviceForRelativeMode = true;
            EngineApp.AllowJoysticksAndCustomInputDevices = true;
            EngineApp.AllowWriteEngineConfigFile          = true;
            EngineApp.AllowChangeVideoMode = true;

            EngineApp.Init(new GameEngineApp());
            EngineApp.Instance.WindowTitle = "Game";

            if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows)
            {
                EngineApp.Instance.Icon = Game.Properties.Resources.Logo;
            }

            EngineConsole.Init();

            EngineApp.Instance.Config.RegisterClassParameters(typeof(GameEngineApp));

            if (EngineApp.Instance.Create())
            {
                EngineApp.Instance.Run();
            }

            EngineApp.Shutdown();

            Log.DumpToFile("Program END\r\n");

            VirtualFileSystem.Shutdown();
        }
Exemple #10
0
        private void EditorForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            //!!!!было в старом
            ////for lost focus in PropertyGrid
            //PropertiesForm.Focus();

            bool?result = ShowDialogAndSaveDocuments(workspaceController.GetDockWindows());

            if (result == null)
            {
                e.Cancel = true;
                return;
            }

            //save docking state
            if (canSaveConfig)
            //if( !forceCloseForm )
            {
                string configFile = VirtualPathUtility.GetRealPathByVirtual(dockingConfigFileName);
                EditorAPI.GetRestartApplication(out _, out var resetWindowsSettings);
                if (resetWindowsSettings)
                {
                    if (File.Exists(configFile))
                    {
                        File.Delete(configFile);
                    }
                }
                else
                {
                    if (!Directory.Exists(Path.GetDirectoryName(configFile)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(configFile));
                    }

                    workspaceController.SaveLayoutToFile(configFile);

                    // temp experimental:
                    //foreach (var wnd in workspaceController.OfType<WorkspaceWindow>())
                    //{
                    //	string configFileName = string.Format(workspaceConfigFileName, wnd.Name);
                    //	string workspaceConfigFile = VirtualPathUtils.GetRealPathByVirtual(configFileName);
                    //	var controller = wnd.WorkspaceController;
                    //	controller.SaveLayoutToFile(workspaceConfigFile);
                    //}
                }
            }

            EditorAPI.ClosingApplication = true;

            EditorLocalization.Shutdown();

            //destroy all documents
            {
                //!!!!может окна документов сначала удалить?
                foreach (var document in Documents.ToArray())
                {
                    document.Destroy();
                }
            }

            //destroy all viewport controls
            foreach (var control in EngineViewportControl.allInstances.ToArray())
            {
                control.Dispose();
            }

            if (!canSaveConfig)
            {
                EngineApp.NeedSaveConfig = false;
            }
            EngineApp.Shutdown();
        }
Exemple #11
0
 //!!!!never call
 public static void ShutdownEngine()
 {
     EngineApp.Shutdown();
     Log.DumpToFile("Program END\r\n");
     VirtualFileSystem.Shutdown();
 }
Exemple #12
0
        static void Main2()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                try
                {
                    //TODO: we can use "app.manifest" and dpiAware prop for .net < 4.7
                    // eg https://medium.com/@EverydayBits/windows-forms-high-dpi-f8bbd70b4dc
                    //
                    //or use DpiAwareness in ApplicationConfigurationSection in  "app.config" for .net >= 4.7
                    // eg https://docs.microsoft.com/ru-ru/dotnet/framework/winforms/high-dpi-support-in-windows-forms
                    //
                    // and we can remove API call SetProcessDPIAware after.

                    SetProcessDPIAware();
                }
                catch { }
            }

            EngineApp.ApplicationType = EngineApp.ApplicationTypeEnum.Editor;

            Log.Handlers.WarningHandler += delegate(string text, ref bool handled, ref bool dumpToLogFile)
            {
                SplashForm.Instance?.Hide();
            };
            Log.Handlers.ErrorHandler += delegate(string text, ref bool handled, ref bool dumpToLogFile)
            {
                SplashForm.Instance?.Hide();
            };
            Log.Handlers.FatalHandler += delegate(string text, string createdLogFilePath, ref bool handled)
            {
                SplashForm.Instance?.Hide();
            };

            //get project's directories
            ProjectUtility.GetDefaultProjectPaths(out string projectDirectory, out string userSettingsDirectory);

            if (!VirtualFileSystem.Init("user:Logs/Editor.log", true, projectDirectory, userSettingsDirectory))
            {
                return;
            }

            //configure general settings
            EngineApp.InitSettings.ConfigVirtualFileName = "user:Configs/Editor.config";

            //!!!!не было
            //!!!!теперь true по дефолту
            //if( SystemSettings.CurrentPlatform == SystemSettings.Platform.Windows )
            //	EngineApp.InitSettings.UseDirectInputForMouseRelativeMode = true;

            //!!!!не включать по дефолту. но нужно раскомментить
            //EngineApp.InitSettings.AllowJoysticksAndSpecialInputDevices= true;
            //!!!!!
            //EngineApp.InitSettings.AllowWriteEngineConfigFile = true;
            //EngineApp.InitSettings.AllowChangeScreenVideoMode = true;
            //Change Floating Point Model for FPU math calculations. Default is Strict53Bits.
            //FloatingPointModel.Model = FloatingPointModel.Models.Strict53Bits;

            EngineApp.Init();
            //EngineApp.Init( new EngineApp() );// EngineApp.ApplicationTypes.Editor ) );
            //EngineApp.Init( new SimulationApp() );

            //!!!!всем в сборке зарегать прост?
            //enable support field and properties serialization for GameEngineApp class.
            //EngineApp.Instance.Config.RegisterClassParameters( typeof( SimulationApp ) );

            //update window
            //!!!!
            //EngineApp.Instance.WindowTitle = "Game";
            //!!!!!чуть ниже стало
            //if( SystemSettings.CurrentPlatform == SystemSettings.Platform.Windows )
            //	EngineApp.Instance.CreatedInsideEngineWindow.Icon = NeoAxis.Game.Properties.Resources.Logo;

            //EngineApp.Instance.SuspendWorkingWhenApplicationIsNotActive = false;

            //!!!!!
            //create and run application loop.
            //if( EngineApp.Instance.Create() )
            //{
            //	//!!!!!
            //	//if( SystemSettings.CurrentPlatform == SystemSettings.Platform.Windows )
            //	//	EngineApp.Instance.CreatedInsideEngineWindow.Icon = NeoAxis.Game.Properties.Resources.Logo;

            //	//EngineApp.Instance.Run();
            //}
            //else
            //{
            //	//!!!!!
            //}

            //Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            EditorForm form = new EditorForm();

            form.Show();
            while (form.Created)
            {
                //!!!!так?

                Application.DoEvents();

                if (EditorForm.Instance == null || EngineApp.Instance == null || EngineApp.Closing)
                {
                    break;
                }

                EditorForm.Instance.RenderViewports(out bool existActiveViewports);
                if (!existActiveViewports && EngineApp.Instance != null)
                {
                    EngineApp.MessageLoopWaitMessage();
                }

                //bool allowRender = MainForm.Instance.Visible &&
                //	MainForm.Instance.WindowState != FormWindowState.Minimized &&
                //	MainForm.Instance.IsAllowRenderScene();

                //if( allowRender )
                //	form.RenderScene();
                //else
                //	EngineApp.Instance.MessageLoopWaitMessage();
            }
            //Application.Run( new EditorForm() );

            EngineApp.Shutdown();
            Log.DumpToFile("Program END\r\n");
            VirtualFileSystem.Shutdown();

            EditorAPI.GetRestartApplication(out var needRestart, out _);
            if (needRestart)
            {
                string fullPath = Process.GetCurrentProcess().MainModule.FileName;
                Process.Start(new ProcessStartInfo(fullPath)
                {
                    UseShellExecute = true
                });
                //Application.Restart();
            }
            else
            {
                //!!!!
                //bug fix for ".NET-BroadcastEventWindow" error
                Application.Exit();
            }

            //	//Mono check
            //	if( RuntimeFramework.Runtime == RuntimeFramework.RuntimeType.Mono )
            //	{
            //		string text = "The Map Editor does not work correctly on the Mono Runtime.\n\nContinue?";
            //		if( MessageBox.Show( text, "Map Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Warning ) == DialogResult.No )
            //			return;
            //	}

            //	if( !VirtualFileSystem.Init( "user:Logs/MapEditor.log", true, null, null, null, null ) )
            //		return;

            //	Log.Handlers.InfoHandler += delegate( string text, ref bool dumpToLogFile )
            //	{
            //		if( MapEditorEngineApp.Instance != null )
            //			MapEditorEngineApp.Instance.AddScreenMessage( text );
            //	};

            //	Log.Handlers.WarningHandler += delegate( string text, ref bool handled, ref bool dumpToLogFile )
            //	{
            //		handled = true;

            //		if( SplashForm.Instance != null )
            //			SplashForm.Instance.Hide();
            //		if( EngineApp.Instance != null )
            //			EngineApp.Instance.ShowSystemCursor = true;

            //		string caption = ToolsLocalization.Translate( "Various", "Warning" );
            //		MessageBox.Show( text, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning );
            //	};

            //	Log.Handlers.ErrorHandler += delegate( string text, ref bool handled, ref bool dumpToLogFile )
            //	{
            //		handled = true;

            //		if( SplashForm.Instance != null )
            //			SplashForm.Instance.Hide();
            //		if( EngineApp.Instance != null )
            //			EngineApp.Instance.ShowSystemCursor = true;

            //		string caption = ToolsLocalization.Translate( "Various", "Error" );
            //		MessageBox.Show( text, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning );
            //	};

            //	Log.Handlers.FatalHandler += delegate( string text, string createdLogFilePath, ref bool handled )
            //	{
            //		if( SplashForm.Instance != null )
            //			SplashForm.Instance.Hide();
            //		if( EngineApp.Instance != null )
            //			EngineApp.Instance.ShowSystemCursor = true;
            //	};

            //	Application.EnableVisualStyles();
            //	Application.SetCompatibleTextRenderingDefault( false );

            //	EngineApp.ConfigName = "user:Configs/MapEditor.config";

            //	EngineApp.Init( new MapEditorEngineApp() );

            //	//Do message loop

            //	MainForm form = new MainForm();
            //	form.Show();
            //	while( form.Created )
            //	{
            //		Application.DoEvents();

            //		if( MainForm.Instance == null )
            //			break;

            //		bool allowRender = MainForm.Instance.Visible &&
            //			MainForm.Instance.WindowState != FormWindowState.Minimized &&
            //			MainForm.Instance.IsAllowRenderScene();

            //		if( allowRender )
            //			form.RenderScene();
            //		else
            //			EngineApp.Instance.MessageLoopWaitMessage();
            //	}
            //}
        }
Exemple #13
0
        static void Main2(Type appMainFormType, bool callSetProcessDPIAware, string logFileName, string configFileName)
        {
            if (callSetProcessDPIAware && Environment.OSVersion.Version.Major >= 6)
            {
                try
                {
                    //TODO: we can use "app.manifest" and dpiAware prop for .net < 4.7
                    // eg https://medium.com/@EverydayBits/windows-forms-high-dpi-f8bbd70b4dc
                    //
                    //or use DpiAwareness in ApplicationConfigurationSection in  "app.config" for .net >= 4.7
                    // eg https://docs.microsoft.com/ru-ru/dotnet/framework/winforms/high-dpi-support-in-windows-forms
                    //
                    // and we can remove API call SetProcessDPIAware after.

                    SetProcessDPIAware();
                }
                catch { }
            }

            EngineApp.ApplicationType = EngineApp.ApplicationTypeEnum.Simulation;

            //get project's directories
            ProjectUtility.GetDefaultProjectPaths(out string projectDirectory, out string userSettingsDirectory);

            if (!VirtualFileSystem.Init(logFileName, true, projectDirectory, userSettingsDirectory))
            {
                return;
            }

            //configure general settings
            EngineApp.InitSettings.ConfigVirtualFileName = configFileName;

            EngineApp.Init();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var form = (Form)appMainFormType.InvokeMember("", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance | BindingFlags.Instance, null, null, null);

            form.Show();
            while (form.Created)
            {
                Application.DoEvents();

                if (/*WidgetAppForm.Instance == null ||*/ EngineApp.Instance == null || EngineApp.Closing)
                {
                    break;
                }

                RenderViewports(form, out bool existActiveViewports);
                if (!existActiveViewports && EngineApp.Instance != null)
                {
                    EngineApp.MessageLoopWaitMessage();
                }
            }
            //Application.Run( form );

            EngineApp.Shutdown();
            Log.DumpToFile("Program END\r\n");
            VirtualFileSystem.Shutdown();

            //!!!!
            //bug fix for ".NET-BroadcastEventWindow" error
            Application.Exit();
        }