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 Log_Handlers_WarningHandler(string text, ref bool handled, ref bool dumpToLogFile) { handled = true; EngineConsole.Print("Warning: " + text, new ColorValue(1, 0, 0)); if (EngineConsole.AutoOpening) { EngineConsole.Active = true; } }
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 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(); }
private static void MainViewport_MouseWheel(Viewport viewport, int delta, ref bool handled) { //Engine console if (EngineConsole.PerformMouseWheel(delta)) { handled = true; return; } //disable input processing if (IsNeedDisableKeyboardAndMouseInput()) { handled = true; return; } }
private static void MainViewport_KeyPress(Viewport viewport, KeyPressEvent e, ref bool handled) { //Engine console if (EngineConsole.PerformKeyPress(e)) { handled = true; return; } //disable input processing if (IsNeedDisableKeyboardAndMouseInput()) { handled = true; return; } }
private static void MainViewport_Touch(Viewport viewport, NeoAxis.Input.TouchData e, ref bool handled) { //Engine console if (EngineConsole.PerformTouch(e)) { handled = true; return; } //disable input processing if (IsNeedDisableKeyboardAndMouseInput()) { handled = true; return; } }
private static void EngineApp_Tick(float delta) { // Perform update viewport, attached scene, UI container. MainViewport.PerformTick(delta); // Process screen messages. ScreenMessages.PerformTick(delta); //engine console EngineConsole.PerformTick(delta); if (firstTick) { FirstTickActions(); } firstTick = false; }
private void m_OnStart() { Time = new Timer(); Input = new InputDevice(this, OnInputKeyEvent, MouseInputEvent); Profiler = new CPUProfiler().Initialize(); Statistics = new StatisticsCollector(); GetEngineConsole = new EngineConsole(this); Debug.EngineConsole = GetEngineConsole; ScriptEngineRef = new ScriptEngine(this); //TODO: create all legacy systems switch (CurrentConfig.RenderBackend) { case EngineConfiguration.RenderBackendEnum.D3D11: RenderBackend = new D3D11RenderBackend(m_Update, m_OnQuit, m_RenderBackandWillRunned, m_OnCharPressed); RenderBackend.Initialize(this, CurrentConfig.InteropDisplay, null); break; } }
static void MainViewport_RenderUI() { //configure cursor file name EngineApp.SystemCursorFileName = "Base\\UI\\Cursors\\DefaultSystem.cur"; //!!!! //Draw UI controls MainViewport.UIContainer.PerformRenderUI(MainViewport.CanvasRenderer); // Process screen messages. ScreenMessages.PerformRenderUI(MainViewport); //viewport statistics if (DisplayViewportStatistics) { var statistics = MainViewport.RenderingContext?.UpdateStatisticsPrevious; if (statistics != null) { var lines = new List <string>(); lines.Add("FPS: " + statistics.FPS.ToString("F1")); lines.Add("Triangles: " + statistics.Triangles.ToString()); lines.Add("Lines: " + statistics.Lines.ToString()); lines.Add("Draw calls: " + statistics.DrawCalls.ToString()); lines.Add("Render targets: " + statistics.RenderTargets.ToString()); lines.Add("Dynamic textures: " + statistics.DynamicTextures.ToString()); lines.Add("Lights: " + statistics.Lights.ToString()); lines.Add("Reflection probes: " + statistics.ReflectionProbes.ToString()); var renderer = MainViewport.CanvasRenderer; var fontSize = renderer.DefaultFontSize; var offset = new Vector2(fontSize * renderer.AspectRatioInv * 0.8, fontSize * 0.6); CanvasRendererUtility.AddTextLinesWithShadow(MainViewport, null, fontSize, lines, new Rectangle(offset.X, offset.Y, 1, 1), EHorizontalAlignment.Left, EVerticalAlignment.Top, new ColorValue(1, 1, 1)); } } //Engine console EngineConsole.PerformRenderUI(); }
protected override void OnDestroy() { MapSystemWorld.MapDestroy(); if (EntitySystemWorld.Instance != null) { EntitySystemWorld.Instance.WorldDestroy(); } Server_DestroyServer("The server has been destroyed"); Client_DisconnectFromServer(); EntitySystemWorld.Shutdown(); GameControlsManager.Shutdown(); ControlsWorld.Shutdown(); controlManager = null; EngineConsole.Shutdown(); instance = null; base.OnDestroy(); }
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 Log_Handlers_ErrorHandler(string text, ref bool handled, ref bool dumpToLogFile) { handled = true; EngineConsole.Print("Error: " + text, new ColorValue(1, 0, 0)); if (EngineConsole.AutoOpening) { EngineConsole.Active = true; } //if( MainViewport != null && MainViewport.UIContainer != null ) //{ // handled = true; // //!!!!! // //find already created MessageBoxWindow // foreach( UIControl control in MainViewport.UIContainer.GetComponents<UIControl>( false ) ) // { // if( control is MessageBoxWindow && !control.RemoveFromParentQueued ) // return; // } // //!!!!! // bool insideTheGame = false; // //bool insideTheGame = GameWindow.Instance != null; // //!!!!! // //if( insideTheGame ) // //{ // // if( Map.Instance != null ) // // { // // if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() ) // // EntitySystemWorld.Instance.Simulation = false; // // } // // EngineApp.Instance.MouseRelativeMode = false; // // DeleteAllGameWindows(); // // MapSystemWorld.MapDestroy(); // // if( EntitySystemWorld.Instance != null ) // // EntitySystemWorld.Instance.WorldDestroy(); // //} // //!!!!! // //GameEngineApp.Instance.Server_DestroyServer( "Error on the server" ); // //GameEngineApp.Instance.Client_DisconnectFromServer(); // //show message box // MessageBoxWindow messageBoxWindow = new MessageBoxWindow( text, "Error", delegate ( UIButton sender ) // { // if( insideTheGame ) // { // //close all windows // foreach( UIControl control in MainViewport.UIContainer.GetComponents<UIControl>( false ) ) // control.RemoveFromParent( true ); // } // else // { // //!!!!! // ////destroy Lobby Window // //foreach( UIControl control in MainViewport.ControlManager.Controls ) // //{ // // if( control is MultiplayerLobbyWindow ) // // { // // control.SetShouldDetach(); // // break; // // } // //} // } // //!!!!! // //if( EntitySystemWorld.Instance == null ) // //{ // // EngineApp.Instance.NeedExit = true; // // return; // //} // //!!!! // ////create main menu // //if( MainMenuWindow.Instance == null ) // // MainViewport.UIContainer.AddComponent( new MainMenuWindow() ); // } ); // MainViewport.UIContainer.AddComponent( messageBoxWindow ); //} }
static void Log_Handlers_InfoHandler(string text, ref bool dumpToLogFile) { EngineConsole.Print(text); }
private static void EngineApp_RegisterConfigParameter(EngineConfig.Parameter parameter) { EngineConsole.RegisterConfigParameter(parameter); }
public static void EngineApp_AppCreateAfter() { Log.Handlers.InvisibleInfoHandler += InvisibleLog_Handlers_InfoHandler; Log.Handlers.InfoHandler += Log_Handlers_InfoHandler; Log.Handlers.WarningHandler += Log_Handlers_WarningHandler; Log.Handlers.ErrorHandler += Log_Handlers_ErrorHandler; Log.Handlers.FatalHandler += Log_Handlers_FatalHandler; EngineApp.RegisterConfigParameter += EngineApp_RegisterConfigParameter; EngineConsole.Init(); //!!!! //GameControlsManager.Init(); //UIControl engineLoadingWindow = ResourceManager.LoadSeparateInstance<UIControl>( "Base\\UI\\Windows\\EngineLoadingWindow.ui", false, null ); //if( engineLoadingWindow != null ) // MainViewport.UIContainer.AddComponent( engineLoadingWindow ); ////Subcribe to callbacks during engine loading. We will render scene from callback. //LongOperationCallbackManager.Subscribe( LongOperationCallbackManager_LoadingCallback, programLoadingWindow ); EngineApp.Tick += EngineApp_Tick; ////finish initialization of materials and hide loading window. ////!!!!!! ////LongOperationCallbackManager.Unsubscribe(); //if( engineLoadingWindow != null ) // engineLoadingWindow.RemoveFromParent( true ); //subscribe to main viewport events { MainViewport.KeyDown += MainViewport_KeyDown; MainViewport.KeyPress += MainViewport_KeyPress; MainViewport.KeyUp += MainViewport_KeyUp; MainViewport.MouseDown += MainViewport_MouseDown; MainViewport.MouseUp += MainViewport_MouseUp; MainViewport.MouseDoubleClick += MainViewport_MouseDoubleClick; MainViewport.MouseMove += MainViewport_MouseMove; MainViewport.MouseWheel += MainViewport_MouseWheel; MainViewport.JoystickEvent += MainViewport_JoystickEvent; MainViewport.SpecialInputDeviceEvent += MainViewport_SpecialInputDeviceEvent; //!!!!!Tick += MainViewport.UpdateBegin += MainViewport_UpdateBegin; MainViewport.UpdateBeforeOutput += MainViewport_UpdateBeforeOutput; MainViewport.UpdateEnd += MainViewport_UpdateEnd; } //change application title if (EngineApp.CreatedInsideEngineWindow != null) { EngineApp.CreatedInsideEngineWindow.Title = ProjectSettings.Get.ProjectName; } //update sound volume if (EngineApp.DefaultSoundChannelGroup != null) { EngineApp.DefaultSoundChannelGroup.Volume = soundVolume; } //create music channel group musicChannelGroup = SoundWorld.CreateChannelGroup("Music"); if (musicChannelGroup != null) { SoundWorld.MasterChannelGroup.AddGroup(musicChannelGroup); musicChannelGroup.Volume = musicVolume; } PlayerInv.Name = "PlayerInv"; PlayerInv.InitialItems.Add("Water, 20"); PlayerInv.InitialItems.Add("Seed, 4"); PlayerInv.InitialItems.Add("Empty, 0"); PlayerInv.InitialItems.Add("Empty, 0"); PlayerInv.InitialItems.Add("Empty, 0"); PlayerInv.CalcInitialItems(); PlayerInv.CalcImagePaths(); }