/////////////////////////////////////////// public static bool InitWithoutCreation(EngineApp engineAppInstance, string logFileName, bool correctCurrentDirectory, string specialExecutableDirectoryPath, string specialResourceDirectoryPath, string specialUserDirectoryPath, string specialNativeLibrariesDirectoryPath) { if (!VirtualFileSystem.Init(logFileName, correctCurrentDirectory, specialExecutableDirectoryPath, specialResourceDirectoryPath, specialUserDirectoryPath, specialNativeLibrariesDirectoryPath)) { return(false); } Log.Handlers.WarningHandler += delegate(string text, ref bool handled, ref bool dumpToLogFile) { handled = true; if (duringOnRender || duringWarningOrErrorMessageBox) { cachedLogMessages.Enqueue(new LogMessage("Warning", text)); } else { duringWarningOrErrorMessageBox = true; MessageBox.Show(text, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); duringWarningOrErrorMessageBox = false; } }; Log.Handlers.ErrorHandler += delegate(string text, ref bool handled, ref bool dumpToLogFile) { handled = true; if (duringOnRender || duringWarningOrErrorMessageBox) { cachedLogMessages.Enqueue(new LogMessage("Error", text)); } else { duringWarningOrErrorMessageBox = true; MessageBox.Show(text, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); duringWarningOrErrorMessageBox = false; } }; //if( System.Environment.OSVersion.Version.Major >= 6 ) //{ // if( MessageBox.Show( // "Do you want to use D3DImage?\n\nD3DImage feature is a new level of interoperability between WPF and DirectX by allowing a custom Direct3D (D3D) surface to be blended with WPF's native D3D surface.", // "D3DImage support", MessageBoxButton.YesNo ) == MessageBoxResult.Yes ) // { // RendererWorld.InitializationOptions.AllowDirectX9Ex = true; // } //} EngineApp.Init(engineAppInstance); updateTimer = new System.Windows.Forms.Timer(); updateTimer.Interval = 100; updateTimer.Tick += updateTimer_Tick; updateTimer.Enabled = true; return(true); }
// public static bool InitWithoutCreation(EngineApp engineAppInstance, string logFileName, bool correctCurrentDirectory, string specialExecutableDirectoryPath, string specialResourceDirectoryPath, string specialUserDirectoryPath, string specialNativeLibrariesDirectoryPath) { if (!VirtualFileSystem.Init(logFileName, correctCurrentDirectory, specialExecutableDirectoryPath, specialResourceDirectoryPath, specialUserDirectoryPath, specialNativeLibrariesDirectoryPath)) { return(false); } Log.Handlers.WarningHandler += delegate(string text, ref bool handled, ref bool dumpToLogFile) { handled = true; duringWarningOrErrorMessageBox = true; MessageBox.Show(text, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); duringWarningOrErrorMessageBox = false; }; Log.Handlers.ErrorHandler += delegate(string text, ref bool handled, ref bool dumpToLogFile) { handled = true; duringWarningOrErrorMessageBox = true; MessageBox.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); duringWarningOrErrorMessageBox = false; }; if (!EngineApp.Init(engineAppInstance)) { return(false); } return(true); }
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()); } }
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, ""); } }
static void Init() { new PlatformFunctionalityUWP(); EngineApp.ApplicationType = EngineApp.ApplicationTypeEnum.Simulation; //get project's directories string projectDirectory = ""; string userSettingsDirectory = ""; { projectDirectory = Windows.ApplicationModel.Package.Current.InstalledLocation.Path; var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder.Path; if (Directory.Exists(localFolder)) { userSettingsDirectory = Path.Combine(localFolder, "User settings"); } else { Log.Fatal("Program: Init: Local folder not found: " + localFolder); } } //ProjectUtility.GetDefaultProjectPaths( out string dataDirectory, 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; EngineApp.InitSettings.AllowJoysticksAndSpecialInputDevices = true; EngineApp.InitSettings.UseDirectInputForMouseRelativeMode = false; // not implemented for UWP //init engine application EngineApp.Init(); //fullscreen is configured in Main() method ////configuring window size is not implemented ////EngineApp.InitSettings.CreateWindowSize = new Vector2I( 320, 240 ); ////EngineApp.InitSettings.CreateWindowState = EngineApp.WindowStateEnum.Maximized; ////EngineApp.InitSettings.CreateWindowState = EngineApp.WindowStateEnum.Normal; ////EngineApp.InitSettings.CreateWindowSize = ( EngineApp.GetScreenSize().ToVector2() * .8 ).ToVector2I(); if (!EngineApp.Create()) { // TODO: implement fail logic } }
///////////////////////////////////////// public static void InitEngine() { Log.Handlers.InvisibleInfoHandler += Log_InvisibleInfoHandler; Log.Handlers.InfoHandler += Log_InfoHandler; Log.Handlers.WarningHandler += Log_WarningHandler; Log.Handlers.ErrorHandler += Log_ErrorHandler; EngineApp.AppCreateBefore += EngineApp_AppCreateBefore; new PlatformFunctionalityAndroid(); EngineApp.ApplicationType = EngineApp.ApplicationTypeEnum.Simulation; ExtractProjectZip(out var projectDir); //get project's directories string projectDirectory = ""; string userSettingsDirectory = ""; string binariesDirectory = ""; { //!!!! projectDirectory = projectDir; userSettingsDirectory = Path.Combine(projectDirectory, "User settings"); binariesDirectory = Path.Combine(projectDirectory, "Binaries"); } if (!VirtualFileSystem.Init("user:Logs/Player.log", true, projectDirectory, userSettingsDirectory, binariesDirectory)) { return; } //configure general settings EngineApp.InitSettings.ConfigVirtualFileName = "user:Configs/Player.config"; //these parameters are enabled by default //EngineApp.EnginePauseWhenApplicationIsNotActive = false; //EngineApp.InitSettings.AllowJoysticksAndSpecialInputDevices = false; //specify Project assembly for scripts EngineApp.ProjectAssembly = typeof(Project.SimulationApp).Assembly; //init engine application EngineApp.Init(); if (!EngineApp.Create()) { Log.Fatal("EngineApp.Create() failed."); return; } }
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(); }
///////////////////////////////////////// public static void WPFInit(string logFileName, string configFileName) { 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(); }
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(); }
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(); // } //} }
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(); }