//

        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;
        }
Пример #2
0
        ///////////////////////////////////////////

        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);
        }
Пример #3
0
        //

        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);
        }
Пример #4
0
        static bool RegisterParameter(string groupPath, string name, FieldInfo field, PropertyInfo property)
        {
            Trace.Assert(field != null || property != null);

            foreach (Parameter parameter in parameters)
            {
                if (parameter.GroupPath == groupPath && parameter.Field == field &&
                    parameter.Property == property)
                {
                    //Log.Error( "Config: Parameter already registered \"{0}\"", groupPath + "\\" + field.Name );
                    return(false);
                }
            }

            Parameter p = new Parameter(groupPath, name, field, property);

            parameters.Add(p);

            if (textBlock != null)
            {
                p.Load(textBlock);
            }

            RegisterConfigParameter?.Invoke(/*this, */ p);
            if (EngineApp.Instance != null)
            {
                EngineApp.PerformRegisterConfigParameter(p);
            }

            return(true);
        }
Пример #5
0
        static void OnConsoleFullscreen(string arguments)
        {
            if (!string.IsNullOrEmpty(arguments))
            {
                try
                {
                    bool value;
                    if (arguments == "1")
                    {
                        value = true;
                    }
                    else if (arguments == "0")
                    {
                        value = false;
                    }
                    else
                    {
                        value = bool.Parse(arguments);
                    }

                    //!!!!
                    EngineApp.SetFullscreenMode(value, EngineApp.FullscreenSize);
                    //EngineApp.Fullscreen = value;
                }
                catch (Exception ex)
                {
                    Log.Warning(ex.Message);
                }
            }
            else
            {
                Print(string.Format("Value: \"{0}\", Default value: \"{1}\"", EngineApp.FullscreenEnabled, true));
            }
        }
Пример #6
0
        private void WidgetControl_Load(object sender, EventArgs e)
        {
            if (EditorUtility.IsDesignerHosted(this))
            {
                return;
            }

            if (MainWidget)
            {
                EngineApp.InitSettings.UseApplicationWindowHandle = Handle;

                if (!EngineApp.Create())
                {
                    //!!!!
                    Log.Fatal("EngineApp.Create() failed.");

                    //Close();
                    return;
                }

                //set viewport control to manage application render window
                renderWindow = RenderingSystem.ApplicationRenderTarget;
                viewport     = renderWindow.Viewports[0];
                PerformResize();
            }

            loaded = true;
        }
Пример #7
0
        static void OnConsoleVideoMode(string arguments)
        {
            if (!string.IsNullOrEmpty(arguments))
            {
                try
                {
                    Vector2I mode = Vector2I.Parse(arguments);

                    if (EngineApp.FullscreenEnabled && !SystemSettings.VideoModeExists(mode))
                    {
                        string text = string.Format("Cannot change screen resolution to \"{0}x{1}\". " +
                                                    "This resolution is not supported by the system.", mode.X, mode.Y);
                        Log.Warning(text);
                        return;
                    }

                    //!!!!
                    EngineApp.SetFullscreenMode(EngineApp.FullscreenEnabled, mode);
                    //EngineApp.Instance.VideoMode = mode;
                }
                catch (Exception ex)
                {
                    Log.Warning(ex.Message);
                }
            }
            else
            {
                Print(string.Format("Value: \"{0}\"", EngineApp.FullscreenSize));
            }
        }
Пример #8
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());
            }
        }
Пример #9
0
        ///////////////////////////////////////////

        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;
        }
Пример #10
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.MaxPixelShadersVersion = RendererWorld.MaxPixelShadersVersions.PS0;
                        //RendererWorld.MaxVertexShadersVersion = RendererWorld.MaxVertexShadersVersions.VS0;
                        //RendererWorld.FullSceneAntialiasing = 0;
                        //RendererWorld.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() );
            }
        }
Пример #11
0
        public void OnDrawFrame(IGL10 gl)
        {
            ////restart engine
            //if( needRestartEngine )
            //{
            //	if( Engine.engineInitialized )
            //	{
            //		//!!!!restart event

            //		//UI thread can be changed when initially app ran with disabled screen. update it.
            //		VirtualFileSystem.SetMainThread( Thread.CurrentThread );

            //		Engine.ShutdownEngine();

            //		Engine.engineInitialized = false;
            //	}

            //	needRestartEngine = false;
            //}

            //init engine
            if (!Engine.engineInitialized)
            {
                try
                {
                    Engine.InitEngine();
                }
                catch (Exception e)
                {
                    Log.FatalAsException(e.ToString());
                    return;
                }
                Engine.engineInitialized = true;
            }

            //UI thread can be changed when initially app ran with disabled screen. update it.
            VirtualFileSystem.SetMainThread(Thread.CurrentThread);

            //update screen size
            if (surfaceResized)
            {
                RenderingSystem.ApplicationRenderTarget?.WindowMovedOrResized(PlatformFunctionalityAndroid.screenSize);
                surfaceResized = false;
            }

            //process input
            Engine.ProcessTouchEvents();

            //engine tick and render
            EngineApp._CreatedWindow_ApplicationIdle(false);

            if (EngineApp.NeedExit)
            {
                Java.Lang.JavaSystem.Exit(0);
            }
        }
Пример #12
0
        protected override void OnPause()
        {
            base.OnPause();

            EngineApp._EnginePause_UpdateState(false, true);

#if OPENGLES
            glSurfaceView.OnPause();
#endif
        }
Пример #13
0
 private void UndoSystem_ListOfActionsChanged(object sender, EventArgs e)
 {
     if (!Destroyed)
     {
         //!!!!is not too much updates?
         EditorUpdateWhenDocumentModified_NeedUpdate(EngineApp.GetSystemTime() + 3.1);
         EditorUpdateWhenDocumentModified_NeedUpdate(EngineApp.GetSystemTime() + 0.5);
         EditorUpdateWhenDocumentModified_NeedUpdate(EngineApp.GetSystemTime());
     }
 }
Пример #14
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, "");
            }
        }
Пример #15
0
        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, "");
            }
        }
 public static bool Init(EngineApp engineAppInstance, Form mainApplicationForm, string logFileName,
     bool correctCurrentDirectory, string specialExecutableDirectoryPath, string specialResourceDirectoryPath,
     string specialUserDirectoryPath, string specialNativeLibrariesDirectoryPath)
 {
     if (!InitWithoutCreation(engineAppInstance, logFileName, correctCurrentDirectory, specialExecutableDirectoryPath,
         specialResourceDirectoryPath, specialUserDirectoryPath, specialNativeLibrariesDirectoryPath))
         return false;
     if (!Create(mainApplicationForm))
         return false;
     return true;
 }
Пример #17
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();
        }
Пример #18
0
        public override void CreatedWindow_SetWindowRectangle(RectangleI rectangle)
        {
            //TODO: implement it.

            var scaleFactor = displayInfo.RawPixelsPerViewPixel;

            applicationView.TryResizeView(new Size(
                                              (rectangle.Right - rectangle.Left) / scaleFactor,
                                              (rectangle.Bottom - rectangle.Top) / scaleFactor));

            //!!!!!так?
            EngineApp._CreatedWindow_ProcessResize();
        }
Пример #19
0
        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
            }
        }
Пример #20
0
        /////////////////////////////////////////

        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;
            }
        }
Пример #21
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();
        }
Пример #22
0
 public static bool Init(EngineApp engineAppInstance, Window mainApplicationWindow, string logFileName,
                         bool correctCurrentDirectory, string specialExecutableDirectoryPath, string specialResourceDirectoryPath,
                         string specialUserDirectoryPath, string specialNativeLibrariesDirectoryPath)
 {
     if (!InitWithoutCreation(engineAppInstance, logFileName, correctCurrentDirectory, specialExecutableDirectoryPath,
                              specialResourceDirectoryPath, specialUserDirectoryPath, specialNativeLibrariesDirectoryPath))
     {
         return(false);
     }
     if (!Create(mainApplicationWindow))
     {
         return(false);
     }
     return(true);
 }
Пример #23
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();
        }
Пример #24
0
        public static void Update()
        {
            EngineToolTip.UpdateAllInstances();

            var control = GetControlOverCursor();

            if (currentControl != control)
            {
                //end old
                currentControl = null;
                currentControlForm?.Close();
                currentControlForm = null;

                //start new
                if (control != null)
                {
                    (EngineToolTip toolTip, string text)tuple = EngineToolTip.GetToolTipByControl(control);
                    if (tuple.toolTip != null && !string.IsNullOrEmpty(tuple.text))
                    {
                        currentControl          = control;
                        currentControlText      = tuple.text;
                        currentControlStartTime = EngineApp.GetSystemTime();
                        currentCursorPosition   = Control.MousePosition;
                    }
                }
            }

            //show form
            if (currentControl != null && currentControlForm == null)
            {
                //reset counter when mouse moved
                if (currentCursorPosition != Control.MousePosition)
                {
                    currentCursorPosition   = Control.MousePosition;
                    currentControlStartTime = EngineApp.GetSystemTime();
                }

                //show form
                if (EngineApp.GetSystemTime() > currentControlStartTime + initialDelay)
                {
                    currentControlForm = new EngineToolTipForm(currentControlText);
                    currentControlForm.StartPosition = FormStartPosition.Manual;
                    var mouse = Control.MousePosition;
                    currentControlForm.Location = new Point(mouse.X, mouse.Y + (int)(16.0f * EditorAPI.DPIScale));
                    currentControlForm.Show();
                }
            }
        }
Пример #25
0
        /////////////////////////////////////////

        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();
        }
Пример #26
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!IsHandleCreated || WinFormsUtility.IsDesignerHosted(this) || EditorAPI.ClosingApplication)
            {
                return;
            }
            if (!WinFormsUtility.IsControlVisibleInHierarchy(this))
            {
                return;
            }

            double updateTime = 0.05;

            {
                var count = EditorForm.Instance.GetObjectsInFocus().Objects.Length;
                if (count > 2000)
                {
                    updateTime = 2.0;
                }
                else if (count > 500)
                {
                    updateTime = 1.0;
                }
                else if (count > 250)
                {
                    updateTime = 0.5;
                }
                else if (count > 100)
                {
                    updateTime = 0.1;
                }
                else
                {
                    updateTime = 0.05;
                }
            }
            if (EngineApp.GetSystemTime() - lastUpdateTime < updateTime)
            {
                return;
            }

            UpdateSelectedPanel();

            lastUpdateTime = EngineApp.GetSystemTime();
        }
Пример #27
0
        protected override void OnDestroy()
        {
            if (EditorUtility.IsDesignerHosted(this))
            {
                return;
            }

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

            base.OnDestroy();
        }
Пример #28
0
        protected override IEnumerator PrepareInterludeAnim()
        {
            EngineApp.StopAssetLoadingCoroutines();

            using (AssetLoaderAsync assetLoader = new AssetLoaderAsync("assets_prefabs", 0, "StartupLoadingUI.prefab", typeof(GameObject)))
            {
                if (assetLoader.asset == null)
                {
                    yield return(StartCoroutine(assetLoader));
                }

                GameObject pref = assetLoader.asset as GameObject;
                if (pref != null)
                {
                    Instantiate(pref);
                }
            }
        }
Пример #29
0
        protected override void OnTick(Viewport viewport, double delta)
        {
            if (pathTest)
            {
                found = false;
                path  = null;
                error = null;

                if (GetPositionByCursor(viewport, out endPosition))
                {
                    var startTime = EngineApp.GetSystemTime();

                    //if( stepSize < .1f )
                    //   stepSize = .1f;
                    //if( polygonPickExtents < .001f )
                    //   polygonPickExtents = .001f;
                    //MathFunctions.Clamp( ref maxPolygonPath, 1, 65536 );
                    //MathFunctions.Clamp( ref maxSmoothPath, 1, 65536 );
                    //MathFunctions.Clamp( ref maxSteerPoints, 1, 256 );

                    var context = new Component_Pathfinding.FindPathContext();
                    context.Start = startPosition;
                    context.End   = endPosition;

                    owner.FindPath(context);

                    found = context.Path != null;
                    path  = context.Path;
                    error = context.Error;

                    //found = owner.FindPath( startPosition, endPosition,
                    //	stepSize, new Vec3( polygonPickExtents, polygonPickExtents, polygonPickExtents ),
                    //	maxPolygonPath, maxSmoothPath, maxSteerPoints, out path );

                    var endTime = EngineApp.GetSystemTime();

                    if ((EngineApp.GetSystemTime() - timeLastUpdateTime) > 0.25)
                    {
                        timeLastUpdateTime = EngineApp.GetSystemTime();
                        time = endTime - startTime;
                    }
                }
            }
        }
Пример #30
0
        public bool IsTimeToUpdate()
        {
            double time = EngineApp.GetSystemTime();
            double step = time - lastRenderTime;

            float invFPS = 0;

            if (automaticUpdateFPS != 0)
            {
                invFPS = 1.0f / automaticUpdateFPS;
            }

            if (step >= invFPS)
            {
                return(true);
            }

            return(false);
        }
Пример #31
0
        public override void CreatedWindow_RunMessageLoop()
        {
            while (!windowClosed)
            {
                if (EngineApp.NeedExit)
                {
                    break;
                }

                if (IsAllowApplicationIdle())
                {
                    // Process events incoming to the window.
                    coreWindow.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent);


                    EngineApp._UpdateEngineTime();
                    double time      = EngineApp.EngineTime;
                    bool   needSleep = EngineApp.MaxFPS != 0 && time < maxFPSLastRenderTime + 1.0f / EngineApp.MaxFPS;

                    if (needSleep)
                    {
                        //!!!!0?
                        Thread.Sleep(1);
                    }
                    else
                    {
                        maxFPSLastRenderTime = time;

                        EngineApp._CreatedWindow_ApplicationIdle(false);

                        if (isSizeChanged)
                        {
                            isSizeChanged = false;
                            EngineApp._CreatedWindow_ProcessResize();
                        }
                    }
                }
                else
                {
                    coreWindow.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessOneAndAllPending);
                }
            }
        }
Пример #32
0
        private void CoreWindow_Activated(CoreWindow sender, WindowActivatedEventArgs args)
        {
            activationState = args.WindowActivationState;

            if (args.WindowActivationState == CoreWindowActivationState.Deactivated)
            {
                //!!!!просто обновляем. ведь внутри и так проверка есть. еще можно зафорсить. но не будет ли так,
                //что отключится слишком быстро? нужно там где включает ставить флаг -> ChangeVUdeMode.
                EngineApp._EnginePause_UpdateState(false, true);

                // do stuff
            }
            else
            {
                // do different stuff
            }

            instance.mustIgnoreOneMouseMoveAtRelativeMode = true;
            instance.CreatedWindow_UpdateShowSystemCursor(true);
        }
Пример #33
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();
        }
Пример #34
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (EditorUtility.IsDesignerHosted(this))
            {
                return;
            }
            if (!loaded)
            {
                return;
            }

            if (MainWidget)
            {
                //!!!!!
                //!!!!где еще вызывать?
                if (EngineApp.Instance != null)
                {
                    EngineApp.DoTick();
                }

                //!!!!
                //UpdateSoundSystem();

                //if( needClose )
                //{
                //	needClose = false;
                //	Close();
                //}

                //if( firstTick )
                //{
                //	firstTick = false;
                //}

                canSaveConfig = true;
                //firstTick = false;
            }
        }
Пример #35
0
 //
 public WinFormsAppEngineApp( EngineApp.ApplicationTypes applicationType )
     : base(applicationType)
 {
     instance = this;
 }